// -*- C++ -*- //===------------------------ propagate_const -----------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef _LIBCUDACXX_EXPERIMENTAL_PROPAGATE_CONST #define _LIBCUDACXX_EXPERIMENTAL_PROPAGATE_CONST /* propagate_const synopsis namespace std { namespace experimental { inline namespace fundamentals_v2 { // [propagate_const] template class propagate_const; // [propagate_const.underlying], underlying pointer access constexpr const _Tp& _CUDA_VSTD_LFTS_V2::get_underlying(const propagate_const& pt) noexcept; constexpr T& _CUDA_VSTD_LFTS_V2::get_underlying(propagate_const& pt) noexcept; // [propagate_const.relational], relational operators template constexpr bool operator==(const propagate_const& pt, nullptr_t); template constexpr bool operator==(nullptr_t, const propagate_const& pu); template constexpr bool operator!=(const propagate_const& pt, nullptr_t); template constexpr bool operator!=(nullptr_t, const propagate_const& pu); template constexpr bool operator==(const propagate_const& pt, const propagate_const<_Up>& pu); template constexpr bool operator!=(const propagate_const& pt, const propagate_const<_Up>& pu); template constexpr bool operator<(const propagate_const& pt, const propagate_const<_Up>& pu); template constexpr bool operator>(const propagate_const& pt, const propagate_const<_Up>& pu); template constexpr bool operator<=(const propagate_const& pt, const propagate_const<_Up>& pu); template constexpr bool operator>=(const propagate_const& pt, const propagate_const<_Up>& pu); template constexpr bool operator==(const propagate_const& pt, const _Up& u); template constexpr bool operator!=(const propagate_const& pt, const _Up& u); template constexpr bool operator<(const propagate_const& pt, const _Up& u); template constexpr bool operator>(const propagate_const& pt, const _Up& u); template constexpr bool operator<=(const propagate_const& pt, const _Up& u); template constexpr bool operator>=(const propagate_const& pt, const _Up& u); template constexpr bool operator==(const _Tp& t, const propagate_const<_Up>& pu); template constexpr bool operator!=(const _Tp& t, const propagate_const<_Up>& pu); template constexpr bool operator<(const _Tp& t, const propagate_const<_Up>& pu); template constexpr bool operator>(const _Tp& t, const propagate_const<_Up>& pu); template constexpr bool operator<=(const _Tp& t, const propagate_const<_Up>& pu); template constexpr bool operator>=(const _Tp& t, const propagate_const<_Up>& pu); // [propagate_const.algorithms], specialized algorithms template constexpr void swap(propagate_const& pt, propagate_const& pu) noexcept(see below); template class propagate_const { public: typedef remove_reference_t())> element_type; // [propagate_const.ctor], constructors constexpr propagate_const() = default; propagate_const(const propagate_const& p) = delete; constexpr propagate_const(propagate_const&& p) = default; template EXPLICIT constexpr propagate_const(propagate_const<_Up>&& pu); // see below template EXPLICIT constexpr propagate_const(U&& u); // see below // [propagate_const.assignment], assignment propagate_const& operator=(const propagate_const& p) = delete; constexpr propagate_const& operator=(propagate_const&& p) = default; template constexpr propagate_const& operator=(propagate_const<_Up>&& pu); template constexpr propagate_const& operator=(U&& u); // see below // [propagate_const.const_observers], const observers explicit constexpr operator bool() const; constexpr const element_type* operator->() const; constexpr operator const element_type*() const; // Not always defined constexpr const element_type& operator*() const; constexpr const element_type* get() const; // [propagate_const.non_const_observers], non-const observers constexpr element_type* operator->(); constexpr operator element_type*(); // Not always defined constexpr element_type& operator*(); constexpr element_type* get(); // [propagate_const.modifiers], modifiers constexpr void swap(propagate_const& pt) noexcept(see below) private: T t_; // exposition only }; } // namespace fundamentals_v2 } // namespace experimental // [propagate_const.hash], hash support template struct hash>; // [propagate_const.comparison_function_objects], comparison function objects template struct equal_to>; template struct not_equal_to>; template struct less>; template struct greater>; template struct less_equal>; template struct greater_equal>; } // namespace std */ #include #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) # pragma GCC system_header #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) # pragma clang system_header #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) # pragma system_header #endif // no system header #if _LIBCUDACXX_STD_VER > 11 #include #include #include _LIBCUDACXX_BEGIN_NAMESPACE_LFTS_V2 template class propagate_const; template inline _LIBCUDACXX_INLINE_VISIBILITY constexpr const _Up& get_underlying(const propagate_const<_Up>& __pu) noexcept; template inline _LIBCUDACXX_INLINE_VISIBILITY constexpr _Up& get_underlying(propagate_const<_Up>& __pu) noexcept; template class propagate_const { public: typedef remove_reference_t())> element_type; static_assert(!is_array<_Tp>::value, "Instantiation of propagate_const with an array type is ill-formed."); static_assert(!is_reference<_Tp>::value, "Instantiation of propagate_const with a reference type is ill-formed."); static_assert(!(is_pointer<_Tp>::value && is_function::type>::value), "Instantiation of propagate_const with a function-pointer type is ill-formed."); static_assert(!(is_pointer<_Tp>::value && is_same::type>::type, void>::value), "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed."); private: template static constexpr element_type* __get_pointer(_Up* __u) { return __u; } template static constexpr element_type* __get_pointer(_Up& __u) { return __get_pointer(__u.get()); } template static constexpr const element_type* __get_pointer(const _Up* __u) { return __u; } template static constexpr const element_type* __get_pointer(const _Up& __u) { return __get_pointer(__u.get()); } template struct __is_propagate_const : false_type { }; template struct __is_propagate_const> : true_type { }; _Tp __t_; public: template friend constexpr const _Up& ::_CUDA_VSTD_LFTS_V2::get_underlying(const propagate_const<_Up>& __pu) noexcept; template friend constexpr _Up& ::_CUDA_VSTD_LFTS_V2::get_underlying(propagate_const<_Up>& __pu) noexcept; constexpr propagate_const() = default; propagate_const(const propagate_const&) = delete; constexpr propagate_const(propagate_const&&) = default; template ::value && is_constructible<_Tp, _Up&&>::value,bool> = true> explicit constexpr propagate_const(propagate_const<_Up>&& __pu) : __t_(std::move(_CUDA_VSTD_LFTS_V2::get_underlying(__pu))) { } template ::value && is_constructible<_Tp, _Up&&>::value,bool> = false> constexpr propagate_const(propagate_const<_Up>&& __pu) : __t_(std::move(_CUDA_VSTD_LFTS_V2::get_underlying(__pu))) { } template ::value && is_constructible<_Tp, _Up&&>::value && !__is_propagate_const>::value,bool> = true> explicit constexpr propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) { } template ::value && is_constructible<_Tp, _Up&&>::value && !__is_propagate_const>::value,bool> = false> constexpr propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) { } propagate_const& operator=(const propagate_const&) = delete; constexpr propagate_const& operator=(propagate_const&&) = default; template constexpr propagate_const& operator=(propagate_const<_Up>&& __pu) { __t_ = std::move(_CUDA_VSTD_LFTS_V2::get_underlying(__pu)); return *this; } template >::value>> constexpr propagate_const& operator=(_Up&& __u) { __t_ = std::forward<_Up>(__u); return *this; } constexpr const element_type* get() const { return __get_pointer(__t_); } constexpr element_type* get() { return __get_pointer(__t_); } explicit constexpr operator bool() const { return get() != nullptr; } constexpr const element_type* operator->() const { return get(); } template ::value>> constexpr operator const element_type *() const { return get(); } constexpr const element_type& operator*() const { return *get(); } constexpr element_type* operator->() { return get(); } template ::value>> constexpr operator element_type *() { return get(); } constexpr element_type& operator*() { return *get(); } constexpr void swap(propagate_const& __pt) noexcept(__is_nothrow_swappable<_Tp>::value) { using _CUDA_VSTD::swap; swap(__t_, __pt.__t_); } }; template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) == nullptr; } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) { return nullptr == _CUDA_VSTD_LFTS_V2::get_underlying(__pt); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) != nullptr; } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) { return nullptr != _CUDA_VSTD_LFTS_V2::get_underlying(__pt); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator==(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) == _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator!=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) != _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator<(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) < _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator>(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) > _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator<=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) <= _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator>=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) >= _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) == __u; } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) != __u; } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) < __u; } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) > __u; } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) <= __u; } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) { return _CUDA_VSTD_LFTS_V2::get_underlying(__pt) >= __u; } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t == _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t != _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t < _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t > _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t <= _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) { return __t >= _CUDA_VSTD_LFTS_V2::get_underlying(__pu); } template _LIBCUDACXX_INLINE_VISIBILITY constexpr void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) noexcept(__is_nothrow_swappable<_Tp>::value) { __pc1.swap(__pc2); } template constexpr const _Tp& get_underlying(const propagate_const<_Tp>& __pt) noexcept { return __pt.__t_; } template constexpr _Tp& get_underlying(propagate_const<_Tp>& __pt) noexcept { return __pt.__t_; } _LIBCUDACXX_END_NAMESPACE_LFTS_V2 _LIBCUDACXX_BEGIN_NAMESPACE_STD template struct hash> { typedef size_t result_type; typedef experimental::fundamentals_v2::propagate_const<_Tp> argument_type; size_t operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1) const { return std::hash<_Tp>()(_CUDA_VSTD_LFTS_V2::get_underlying(__pc1)); } }; template struct equal_to> { typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const { return std::equal_to<_Tp>()(_CUDA_VSTD_LFTS_V2::get_underlying(__pc1), _CUDA_VSTD_LFTS_V2::get_underlying(__pc2)); } }; template struct not_equal_to> { typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const { return std::not_equal_to<_Tp>()(_CUDA_VSTD_LFTS_V2::get_underlying(__pc1), _CUDA_VSTD_LFTS_V2::get_underlying(__pc2)); } }; template struct less> { typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const { return std::less<_Tp>()(_CUDA_VSTD_LFTS_V2::get_underlying(__pc1), _CUDA_VSTD_LFTS_V2::get_underlying(__pc2)); } }; template struct greater> { typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const { return std::greater<_Tp>()(_CUDA_VSTD_LFTS_V2::get_underlying(__pc1), _CUDA_VSTD_LFTS_V2::get_underlying(__pc2)); } }; template struct less_equal> { typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const { return std::less_equal<_Tp>()(_CUDA_VSTD_LFTS_V2::get_underlying(__pc1), _CUDA_VSTD_LFTS_V2::get_underlying(__pc2)); } }; template struct greater_equal> { typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const { return std::greater_equal<_Tp>()(_CUDA_VSTD_LFTS_V2::get_underlying(__pc1), _CUDA_VSTD_LFTS_V2::get_underlying(__pc2)); } }; _LIBCUDACXX_END_NAMESPACE_STD #endif // _LIBCUDACXX_STD_VER > 11 #endif // _LIBCUDACXX_EXPERIMENTAL_PROPAGATE_CONST