propagate_const 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
  10. #define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST
  11. /*
  12. propagate_const synopsis
  13. namespace std { namespace experimental { inline namespace fundamentals_v2 {
  14. // [propagate_const]
  15. template <class T> class propagate_const;
  16. // [propagate_const.underlying], underlying pointer access
  17. constexpr const _Tp& get_underlying(const propagate_const<T>& pt) noexcept;
  18. constexpr T& get_underlying(propagate_const<T>& pt) noexcept;
  19. // [propagate_const.relational], relational operators
  20. template <class T> constexpr bool operator==(const propagate_const<T>& pt, nullptr_t);
  21. template <class T> constexpr bool operator==(nullptr_t, const propagate_const<T>& pu);
  22. template <class T> constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t);
  23. template <class T> constexpr bool operator!=(nullptr_t, const propagate_const<T>& pu);
  24. template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
  25. template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
  26. template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
  27. template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
  28. template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
  29. template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const propagate_const<_Up>& pu);
  30. template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const _Up& u);
  31. template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const _Up& u);
  32. template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const _Up& u);
  33. template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const _Up& u);
  34. template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const _Up& u);
  35. template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const _Up& u);
  36. template <class T, class U> constexpr bool operator==(const _Tp& t, const propagate_const<_Up>& pu);
  37. template <class T, class U> constexpr bool operator!=(const _Tp& t, const propagate_const<_Up>& pu);
  38. template <class T, class U> constexpr bool operator<(const _Tp& t, const propagate_const<_Up>& pu);
  39. template <class T, class U> constexpr bool operator>(const _Tp& t, const propagate_const<_Up>& pu);
  40. template <class T, class U> constexpr bool operator<=(const _Tp& t, const propagate_const<_Up>& pu);
  41. template <class T, class U> constexpr bool operator>=(const _Tp& t, const propagate_const<_Up>& pu);
  42. // [propagate_const.algorithms], specialized algorithms
  43. template <class T> constexpr void swap(propagate_const<T>& pt, propagate_const<T>& pu) noexcept(see below);
  44. template <class T>
  45. class propagate_const
  46. {
  47. public:
  48. typedef remove_reference_t<decltype(*declval<T&>())> element_type;
  49. // [propagate_const.ctor], constructors
  50. constexpr propagate_const() = default;
  51. propagate_const(const propagate_const& p) = delete;
  52. constexpr propagate_const(propagate_const&& p) = default;
  53. template <class U> EXPLICIT constexpr propagate_const(propagate_const<_Up>&& pu); // see below
  54. template <class U> EXPLICIT constexpr propagate_const(U&& u); // see below
  55. // [propagate_const.assignment], assignment
  56. propagate_const& operator=(const propagate_const& p) = delete;
  57. constexpr propagate_const& operator=(propagate_const&& p) = default;
  58. template <class U> constexpr propagate_const& operator=(propagate_const<_Up>&& pu);
  59. template <class U> constexpr propagate_const& operator=(U&& u); // see below
  60. // [propagate_const.const_observers], const observers
  61. explicit constexpr operator bool() const;
  62. constexpr const element_type* operator->() const;
  63. constexpr operator const element_type*() const; // Not always defined
  64. constexpr const element_type& operator*() const;
  65. constexpr const element_type* get() const;
  66. // [propagate_const.non_const_observers], non-const observers
  67. constexpr element_type* operator->();
  68. constexpr operator element_type*(); // Not always defined
  69. constexpr element_type& operator*();
  70. constexpr element_type* get();
  71. // [propagate_const.modifiers], modifiers
  72. constexpr void swap(propagate_const& pt) noexcept(see below)
  73. private:
  74. T t_; // exposition only
  75. };
  76. } // namespace fundamentals_v2
  77. } // namespace experimental
  78. // [propagate_const.hash], hash support
  79. template <class T> struct hash<experimental::propagate_const<T>>;
  80. // [propagate_const.comparison_function_objects], comparison function objects
  81. template <class T> struct equal_to<experimental::propagate_const<T>>;
  82. template <class T> struct not_equal_to<experimental::propagate_const<T>>;
  83. template <class T> struct less<experimental::propagate_const<T>>;
  84. template <class T> struct greater<experimental::propagate_const<T>>;
  85. template <class T> struct less_equal<experimental::propagate_const<T>>;
  86. template <class T> struct greater_equal<experimental::propagate_const<T>>;
  87. } // namespace std
  88. */
  89. #include <__functional/operations.h>
  90. #include <__fwd/functional.h>
  91. #include <__type_traits/conditional.h>
  92. #include <__type_traits/decay.h>
  93. #include <__type_traits/enable_if.h>
  94. #include <__type_traits/is_array.h>
  95. #include <__type_traits/is_constructible.h>
  96. #include <__type_traits/is_convertible.h>
  97. #include <__type_traits/is_function.h>
  98. #include <__type_traits/is_pointer.h>
  99. #include <__type_traits/is_reference.h>
  100. #include <__type_traits/is_same.h>
  101. #include <__type_traits/is_swappable.h>
  102. #include <__type_traits/remove_cv.h>
  103. #include <__type_traits/remove_pointer.h>
  104. #include <__type_traits/remove_reference.h>
  105. #include <__utility/declval.h>
  106. #include <__utility/forward.h>
  107. #include <__utility/move.h>
  108. #include <__utility/swap.h>
  109. #include <cstddef>
  110. #include <experimental/__config>
  111. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  112. # pragma GCC system_header
  113. #endif
  114. _LIBCPP_PUSH_MACROS
  115. #include <__undef_macros>
  116. #if _LIBCPP_STD_VER >= 14
  117. _LIBCPP_BEGIN_NAMESPACE_LFTS_V2
  118. template <class _Tp>
  119. class propagate_const;
  120. template <class _Up>
  121. inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
  122. template <class _Up>
  123. inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
  124. template <class _Tp>
  125. class propagate_const {
  126. public:
  127. typedef remove_reference_t<decltype(*std::declval<_Tp&>())> element_type;
  128. static_assert(!is_array<_Tp>::value, "Instantiation of propagate_const with an array type is ill-formed.");
  129. static_assert(!is_reference<_Tp>::value, "Instantiation of propagate_const with a reference type is ill-formed.");
  130. static_assert(!(is_pointer<_Tp>::value && is_function<__remove_pointer_t<_Tp> >::value),
  131. "Instantiation of propagate_const with a function-pointer type is ill-formed.");
  132. static_assert(!(is_pointer<_Tp>::value && is_same<__remove_cv_t<__remove_pointer_t<_Tp> >, void>::value),
  133. "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed.");
  134. private:
  135. template <class _Up>
  136. static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u) {
  137. return __u;
  138. }
  139. template <class _Up>
  140. static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u) {
  141. return __get_pointer(__u.get());
  142. }
  143. template <class _Up>
  144. static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u) {
  145. return __u;
  146. }
  147. template <class _Up>
  148. static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u) {
  149. return __get_pointer(__u.get());
  150. }
  151. template <class _Up>
  152. struct __is_propagate_const : false_type {};
  153. template <class _Up>
  154. struct __is_propagate_const<propagate_const<_Up>> : true_type {};
  155. _Tp __t_;
  156. public:
  157. template <class _Up>
  158. friend _LIBCPP_CONSTEXPR const _Up&
  159. experimental::fundamentals_v2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
  160. template <class _Up>
  161. friend _LIBCPP_CONSTEXPR _Up& experimental::fundamentals_v2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
  162. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const() = default;
  163. propagate_const(const propagate_const&) = delete;
  164. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default;
  165. template <class _Up,
  166. enable_if_t<!is_convertible<_Up, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = true>
  167. explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
  168. : __t_(std::move(experimental::get_underlying(__pu))) {}
  169. template <class _Up,
  170. enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = false>
  171. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
  172. : __t_(std::move(experimental::get_underlying(__pu))) {}
  173. template <class _Up,
  174. enable_if_t<!is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value &&
  175. !__is_propagate_const<decay_t<_Up>>::value,
  176. bool> = true>
  177. explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {}
  178. template <class _Up,
  179. enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value &&
  180. !__is_propagate_const<decay_t<_Up>>::value,
  181. bool> = false>
  182. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {}
  183. propagate_const& operator=(const propagate_const&) = delete;
  184. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default;
  185. template <class _Up>
  186. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu) {
  187. __t_ = std::move(experimental::get_underlying(__pu));
  188. return *this;
  189. }
  190. template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>>
  191. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u) {
  192. __t_ = std::forward<_Up>(__u);
  193. return *this;
  194. }
  195. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* get() const { return __get_pointer(__t_); }
  196. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* get() { return __get_pointer(__t_); }
  197. _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR operator bool() const { return get() != nullptr; }
  198. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* operator->() const { return get(); }
  199. template <class _Dummy = _Tp, class _Up = enable_if_t<is_convertible< const _Dummy, const element_type*>::value>>
  200. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator const element_type*() const {
  201. return get();
  202. }
  203. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type& operator*() const { return *get(); }
  204. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* operator->() { return get(); }
  205. template <class _Dummy = _Tp, class _Up = enable_if_t< is_convertible<_Dummy, element_type*>::value>>
  206. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator element_type*() {
  207. return get();
  208. }
  209. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type& operator*() { return *get(); }
  210. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const& __pt)
  211. _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
  212. using std::swap;
  213. swap(__t_, __pt.__t_);
  214. }
  215. };
  216. template <class _Tp>
  217. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) {
  218. return experimental::get_underlying(__pt) == nullptr;
  219. }
  220. template <class _Tp>
  221. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) {
  222. return nullptr == experimental::get_underlying(__pt);
  223. }
  224. template <class _Tp>
  225. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) {
  226. return experimental::get_underlying(__pt) != nullptr;
  227. }
  228. template <class _Tp>
  229. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) {
  230. return nullptr != experimental::get_underlying(__pt);
  231. }
  232. template <class _Tp, class _Up>
  233. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
  234. operator==(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
  235. return experimental::get_underlying(__pt) == experimental::get_underlying(__pu);
  236. }
  237. template <class _Tp, class _Up>
  238. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
  239. operator!=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
  240. return experimental::get_underlying(__pt) != experimental::get_underlying(__pu);
  241. }
  242. template <class _Tp, class _Up>
  243. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
  244. operator<(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
  245. return experimental::get_underlying(__pt) < experimental::get_underlying(__pu);
  246. }
  247. template <class _Tp, class _Up>
  248. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
  249. operator>(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
  250. return experimental::get_underlying(__pt) > experimental::get_underlying(__pu);
  251. }
  252. template <class _Tp, class _Up>
  253. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
  254. operator<=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
  255. return experimental::get_underlying(__pt) <= experimental::get_underlying(__pu);
  256. }
  257. template <class _Tp, class _Up>
  258. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
  259. operator>=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
  260. return experimental::get_underlying(__pt) >= experimental::get_underlying(__pu);
  261. }
  262. template <class _Tp, class _Up>
  263. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) {
  264. return experimental::get_underlying(__pt) == __u;
  265. }
  266. template <class _Tp, class _Up>
  267. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) {
  268. return experimental::get_underlying(__pt) != __u;
  269. }
  270. template <class _Tp, class _Up>
  271. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) {
  272. return experimental::get_underlying(__pt) < __u;
  273. }
  274. template <class _Tp, class _Up>
  275. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) {
  276. return experimental::get_underlying(__pt) > __u;
  277. }
  278. template <class _Tp, class _Up>
  279. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) {
  280. return experimental::get_underlying(__pt) <= __u;
  281. }
  282. template <class _Tp, class _Up>
  283. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) {
  284. return experimental::get_underlying(__pt) >= __u;
  285. }
  286. template <class _Tp, class _Up>
  287. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) {
  288. return __t == experimental::get_underlying(__pu);
  289. }
  290. template <class _Tp, class _Up>
  291. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) {
  292. return __t != experimental::get_underlying(__pu);
  293. }
  294. template <class _Tp, class _Up>
  295. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) {
  296. return __t < experimental::get_underlying(__pu);
  297. }
  298. template <class _Tp, class _Up>
  299. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) {
  300. return __t > experimental::get_underlying(__pu);
  301. }
  302. template <class _Tp, class _Up>
  303. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) {
  304. return __t <= experimental::get_underlying(__pu);
  305. }
  306. template <class _Tp, class _Up>
  307. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) {
  308. return __t >= experimental::get_underlying(__pu);
  309. }
  310. template <class _Tp>
  311. _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2)
  312. _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
  313. __pc1.swap(__pc2);
  314. }
  315. template <class _Tp>
  316. _LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT {
  317. return __pt.__t_;
  318. }
  319. template <class _Tp>
  320. _LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT {
  321. return __pt.__t_;
  322. }
  323. _LIBCPP_END_NAMESPACE_LFTS_V2
  324. _LIBCPP_BEGIN_NAMESPACE_STD
  325. template <class _Tp>
  326. struct hash<experimental::propagate_const<_Tp>> {
  327. typedef size_t result_type;
  328. typedef experimental::propagate_const<_Tp> argument_type;
  329. _LIBCPP_HIDE_FROM_ABI size_t operator()(const experimental::propagate_const<_Tp>& __pc1) const {
  330. return std::hash<_Tp>()(experimental::get_underlying(__pc1));
  331. }
  332. };
  333. template <class _Tp>
  334. struct equal_to<experimental::propagate_const<_Tp>> {
  335. typedef experimental::propagate_const<_Tp> first_argument_type;
  336. typedef experimental::propagate_const<_Tp> second_argument_type;
  337. _LIBCPP_HIDE_FROM_ABI bool
  338. operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const {
  339. return std::equal_to<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2));
  340. }
  341. };
  342. template <class _Tp>
  343. struct not_equal_to<experimental::propagate_const<_Tp>> {
  344. typedef experimental::propagate_const<_Tp> first_argument_type;
  345. typedef experimental::propagate_const<_Tp> second_argument_type;
  346. _LIBCPP_HIDE_FROM_ABI bool
  347. operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const {
  348. return std::not_equal_to<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2));
  349. }
  350. };
  351. template <class _Tp>
  352. struct less<experimental::propagate_const<_Tp>> {
  353. typedef experimental::propagate_const<_Tp> first_argument_type;
  354. typedef experimental::propagate_const<_Tp> second_argument_type;
  355. _LIBCPP_HIDE_FROM_ABI bool
  356. operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const {
  357. return std::less<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2));
  358. }
  359. };
  360. template <class _Tp>
  361. struct greater<experimental::propagate_const<_Tp>> {
  362. typedef experimental::propagate_const<_Tp> first_argument_type;
  363. typedef experimental::propagate_const<_Tp> second_argument_type;
  364. _LIBCPP_HIDE_FROM_ABI bool
  365. operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const {
  366. return std::greater<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2));
  367. }
  368. };
  369. template <class _Tp>
  370. struct less_equal<experimental::propagate_const<_Tp>> {
  371. typedef experimental::propagate_const<_Tp> first_argument_type;
  372. typedef experimental::propagate_const<_Tp> second_argument_type;
  373. _LIBCPP_HIDE_FROM_ABI bool
  374. operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const {
  375. return std::less_equal<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2));
  376. }
  377. };
  378. template <class _Tp>
  379. struct greater_equal<experimental::propagate_const<_Tp>> {
  380. typedef experimental::propagate_const<_Tp> first_argument_type;
  381. typedef experimental::propagate_const<_Tp> second_argument_type;
  382. _LIBCPP_HIDE_FROM_ABI bool
  383. operator()(const experimental::propagate_const<_Tp>& __pc1, const experimental::propagate_const<_Tp>& __pc2) const {
  384. return std::greater_equal<_Tp>()(experimental::get_underlying(__pc1), experimental::get_underlying(__pc2));
  385. }
  386. };
  387. _LIBCPP_END_NAMESPACE_STD
  388. #endif // _LIBCPP_STD_VER >= 14
  389. _LIBCPP_POP_MACROS
  390. #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
  391. # include <type_traits>
  392. #endif
  393. #endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST