Jonathan Coe | 945cacc | 2016-06-19 19:34:13 +0000 | [diff] [blame^] | 1 | // -*- C++ -*- |
| 2 | //===------------------------ propagate_const -----------------------------===// |
| 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
| 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST |
| 12 | #define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST |
| 13 | /* |
| 14 | propagate_const synopsis |
| 15 | |
| 16 | namespace std { namespace experimental { inline namespace fundamentals_v2 { |
| 17 | |
| 18 | // [propagate_const] |
| 19 | template <class T> class propagate_const; |
| 20 | |
| 21 | // [propagate_const.underlying], underlying pointer access |
| 22 | constexpr const _Tp& _VSTD_LFTS_V2::get_underlying(const propagate_const<T>& pt) noexcept; |
| 23 | constexpr T& _VSTD_LFTS_V2::get_underlying(propagate_const<T>& pt) noexcept; |
| 24 | |
| 25 | // [propagate_const.relational], relational operators |
| 26 | template <class T> constexpr bool operator==(const propagate_const<T>& pt, nullptr_t); |
| 27 | template <class T> constexpr bool operator==(nullptr_t, const propagate_const<T>& pu); |
| 28 | template <class T> constexpr bool operator!=(const propagate_const<T>& pt, nullptr_t); |
| 29 | template <class T> constexpr bool operator!=(nullptr_t, const propagate_const<T>& pu); |
| 30 | template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const propagate_const<_Up>& pu); |
| 31 | template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); |
| 32 | template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const propagate_const<_Up>& pu); |
| 33 | template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const propagate_const<_Up>& pu); |
| 34 | template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); |
| 35 | template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const propagate_const<_Up>& pu); |
| 36 | template <class T, class U> constexpr bool operator==(const propagate_const<T>& pt, const _Up& u); |
| 37 | template <class T, class U> constexpr bool operator!=(const propagate_const<T>& pt, const _Up& u); |
| 38 | template <class T, class U> constexpr bool operator<(const propagate_const<T>& pt, const _Up& u); |
| 39 | template <class T, class U> constexpr bool operator>(const propagate_const<T>& pt, const _Up& u); |
| 40 | template <class T, class U> constexpr bool operator<=(const propagate_const<T>& pt, const _Up& u); |
| 41 | template <class T, class U> constexpr bool operator>=(const propagate_const<T>& pt, const _Up& u); |
| 42 | template <class T, class U> constexpr bool operator==(const _Tp& t, const propagate_const<_Up>& pu); |
| 43 | template <class T, class U> constexpr bool operator!=(const _Tp& t, const propagate_const<_Up>& pu); |
| 44 | template <class T, class U> constexpr bool operator<(const _Tp& t, const propagate_const<_Up>& pu); |
| 45 | template <class T, class U> constexpr bool operator>(const _Tp& t, const propagate_const<_Up>& pu); |
| 46 | template <class T, class U> constexpr bool operator<=(const _Tp& t, const propagate_const<_Up>& pu); |
| 47 | template <class T, class U> constexpr bool operator>=(const _Tp& t, const propagate_const<_Up>& pu); |
| 48 | |
| 49 | // [propagate_const.algorithms], specialized algorithms |
| 50 | template <class T> constexpr void swap(propagate_const<T>& pt, propagate_const<T>& pu) noexcept(see below); |
| 51 | |
| 52 | template <class T> |
| 53 | class propagate_const |
| 54 | { |
| 55 | |
| 56 | public: |
| 57 | typedef remove_reference_t<decltype(*declval<T&>())> element_type; |
| 58 | |
| 59 | // [propagate_const.ctor], constructors |
| 60 | constexpr propagate_const() = default; |
| 61 | propagate_const(const propagate_const& p) = delete; |
| 62 | constexpr propagate_const(propagate_const&& p) = default; |
| 63 | template <class U> EXPLICIT constexpr propagate_const(propagate_const<_Up>&& pu); // see below |
| 64 | template <class U> EXPLICIT constexpr propagate_const(U&& u); // see below |
| 65 | |
| 66 | // [propagate_const.assignment], assignment |
| 67 | propagate_const& operator=(const propagate_const& p) = delete; |
| 68 | constexpr propagate_const& operator=(propagate_const&& p) = default; |
| 69 | template <class U> constexpr propagate_const& operator=(propagate_const<_Up>&& pu); |
| 70 | template <class U> constexpr propagate_const& operator=(U&& u); // see below |
| 71 | |
| 72 | // [propagate_const.const_observers], const observers |
| 73 | explicit constexpr operator bool() const; |
| 74 | constexpr const element_type* operator->() const; |
| 75 | constexpr operator const element_type*() const; // Not always defined |
| 76 | constexpr const element_type& operator*() const; |
| 77 | constexpr const element_type* get() const; |
| 78 | |
| 79 | // [propagate_const.non_const_observers], non-const observers |
| 80 | constexpr element_type* operator->(); |
| 81 | constexpr operator element_type*(); // Not always defined |
| 82 | constexpr element_type& operator*(); |
| 83 | constexpr element_type* get(); |
| 84 | |
| 85 | // [propagate_const.modifiers], modifiers |
| 86 | constexpr void swap(propagate_const& pt) noexcept(see below) |
| 87 | |
| 88 | private: |
| 89 | T t_; // exposition only |
| 90 | }; |
| 91 | |
| 92 | } // namespace fundamentals_v2 |
| 93 | } // namespace experimental |
| 94 | |
| 95 | // [propagate_const.hash], hash support |
| 96 | template <class T> struct hash<experimental::fundamentals_v2::propagate_const<T>>; |
| 97 | |
| 98 | // [propagate_const.comparison_function_objects], comparison function objects |
| 99 | template <class T> struct equal_to<experimental::fundamentals_v2::propagate_const<T>>; |
| 100 | template <class T> struct not_equal_to<experimental::fundamentals_v2::propagate_const<T>>; |
| 101 | template <class T> struct less<experimental::fundamentals_v2::propagate_const<T>>; |
| 102 | template <class T> struct greater<experimental::fundamentals_v2::propagate_const<T>>; |
| 103 | template <class T> struct less_equal<experimental::fundamentals_v2::propagate_const<T>>; |
| 104 | template <class T> struct greater_equal<experimental::fundamentals_v2::propagate_const<T>>; |
| 105 | |
| 106 | } // namespace std |
| 107 | |
| 108 | */ |
| 109 | |
| 110 | #include <experimental/__config> |
| 111 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 112 | #pragma GCC system_header |
| 113 | #endif |
| 114 | |
| 115 | #if _LIBCPP_STD_VER > 11 |
| 116 | |
| 117 | #include <type_traits> |
| 118 | #include <utility> |
| 119 | #include <functional> |
| 120 | |
| 121 | _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 |
| 122 | |
| 123 | |
| 124 | template <class _Tp> |
| 125 | class propagate_const; |
| 126 | template <class _Up> _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; |
| 127 | template <class _Up> _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; |
| 128 | |
| 129 | template <class _Tp> |
| 130 | class propagate_const |
| 131 | { |
| 132 | public: |
| 133 | typedef remove_reference_t<decltype(*_VSTD::declval<_Tp&>())> element_type; |
| 134 | |
| 135 | static_assert(!is_array<_Tp>::value, |
| 136 | "Instantiation of propagate_const with an array type is ill-formed."); |
| 137 | static_assert(!is_reference<_Tp>::value, |
| 138 | "Instantiation of propagate_const with a reference type is ill-formed."); |
| 139 | static_assert(!(is_pointer<_Tp>::value && is_function<typename remove_pointer<_Tp>::type>::value), |
| 140 | "Instantiation of propagate_const with a function-pointer type is ill-formed."); |
| 141 | static_assert(!(is_pointer<_Tp>::value && is_same<typename remove_cv<typename remove_pointer<_Tp>::type>::type, void>::value), |
| 142 | "Instantiation of propagate_const with a pointer to (possibly cv-qualified) void is ill-formed."); |
| 143 | |
| 144 | private: |
| 145 | template <class _Up> |
| 146 | static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u) |
| 147 | { |
| 148 | return __u; |
| 149 | } |
| 150 | |
| 151 | template <class _Up> |
| 152 | static _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u) |
| 153 | { |
| 154 | return __get_pointer(__u.get()); |
| 155 | } |
| 156 | |
| 157 | template <class _Up> |
| 158 | static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u) |
| 159 | { |
| 160 | return __u; |
| 161 | } |
| 162 | |
| 163 | template <class _Up> |
| 164 | static _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u) |
| 165 | { |
| 166 | return __get_pointer(__u.get()); |
| 167 | } |
| 168 | |
| 169 | template <class _Up> |
| 170 | struct __is_propagate_const : false_type |
| 171 | { |
| 172 | }; |
| 173 | |
| 174 | template <class _Up> |
| 175 | struct __is_propagate_const<propagate_const<_Up>> : true_type |
| 176 | { |
| 177 | }; |
| 178 | |
| 179 | _Tp __t_; |
| 180 | |
| 181 | public: |
| 182 | |
| 183 | template <class _Up> friend _LIBCPP_CONSTEXPR const _Up& ::_VSTD_LFTS_V2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT; |
| 184 | template <class _Up> friend _LIBCPP_CONSTEXPR _Up& ::_VSTD_LFTS_V2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT; |
| 185 | |
| 186 | _LIBCPP_CONSTEXPR propagate_const() = default; |
| 187 | |
| 188 | propagate_const(const propagate_const&) = delete; |
| 189 | |
| 190 | _LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default; |
| 191 | |
| 192 | template <class _Up, enable_if_t<!is_convertible<_Up, _Tp>::value && |
| 193 | is_constructible<_Tp, _Up&&>::value,bool> = true> |
| 194 | explicit _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) |
| 195 | : __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu))) |
| 196 | { |
| 197 | } |
| 198 | |
| 199 | template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value && |
| 200 | is_constructible<_Tp, _Up&&>::value,bool> = false> |
| 201 | _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu) |
| 202 | : __t_(std::move(_VSTD_LFTS_V2::get_underlying(__pu))) |
| 203 | { |
| 204 | } |
| 205 | |
| 206 | template <class _Up, enable_if_t<!is_convertible<_Up&&, _Tp>::value && |
| 207 | is_constructible<_Tp, _Up&&>::value && |
| 208 | !__is_propagate_const<decay_t<_Up>>::value,bool> = true> |
| 209 | explicit _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) |
| 210 | : __t_(std::forward<_Up>(__u)) |
| 211 | { |
| 212 | } |
| 213 | |
| 214 | template <class _Up, enable_if_t<is_convertible<_Up&&, _Tp>::value && |
| 215 | is_constructible<_Tp, _Up&&>::value && |
| 216 | !__is_propagate_const<decay_t<_Up>>::value,bool> = false> |
| 217 | _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) |
| 218 | : __t_(std::forward<_Up>(__u)) |
| 219 | { |
| 220 | } |
| 221 | |
| 222 | propagate_const& operator=(const propagate_const&) = delete; |
| 223 | |
| 224 | _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default; |
| 225 | |
| 226 | template <class _Up> |
| 227 | _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu) |
| 228 | { |
| 229 | __t_ = std::move(_VSTD_LFTS_V2::get_underlying(__pu)); |
| 230 | return *this; |
| 231 | } |
| 232 | |
| 233 | template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>> |
| 234 | _LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u) |
| 235 | { |
| 236 | __t_ = std::forward<_Up>(__u); |
| 237 | return *this; |
| 238 | } |
| 239 | |
| 240 | _LIBCPP_CONSTEXPR const element_type* get() const |
| 241 | { |
| 242 | return __get_pointer(__t_); |
| 243 | } |
| 244 | |
| 245 | _LIBCPP_CONSTEXPR element_type* get() |
| 246 | { |
| 247 | return __get_pointer(__t_); |
| 248 | } |
| 249 | |
| 250 | explicit _LIBCPP_CONSTEXPR operator bool() const |
| 251 | { |
| 252 | return get() != nullptr; |
| 253 | } |
| 254 | |
| 255 | _LIBCPP_CONSTEXPR const element_type* operator->() const |
| 256 | { |
| 257 | return get(); |
| 258 | } |
| 259 | |
| 260 | template <class _Tp_ = _Tp, class _Up = enable_if_t<is_convertible< |
| 261 | const _Tp_, const element_type *>::value>> |
| 262 | _LIBCPP_CONSTEXPR operator const element_type *() const { |
| 263 | return get(); |
| 264 | } |
| 265 | |
| 266 | _LIBCPP_CONSTEXPR const element_type& operator*() const |
| 267 | { |
| 268 | return *get(); |
| 269 | } |
| 270 | |
| 271 | _LIBCPP_CONSTEXPR element_type* operator->() |
| 272 | { |
| 273 | return get(); |
| 274 | } |
| 275 | |
| 276 | template <class _Tp_ = _Tp, class _Up = enable_if_t< |
| 277 | is_convertible<_Tp_, element_type *>::value>> |
| 278 | _LIBCPP_CONSTEXPR operator element_type *() { |
| 279 | return get(); |
| 280 | } |
| 281 | |
| 282 | _LIBCPP_CONSTEXPR element_type& operator*() |
| 283 | { |
| 284 | return *get(); |
| 285 | } |
| 286 | |
| 287 | _LIBCPP_CONSTEXPR void swap(propagate_const& __pt) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) |
| 288 | { |
| 289 | using _VSTD::swap; |
| 290 | swap(__t_, __pt.__t_); |
| 291 | } |
| 292 | }; |
| 293 | |
| 294 | |
| 295 | template <class _Tp> |
| 296 | _LIBCPP_INLINE_VISIBILITY |
| 297 | _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) |
| 298 | { |
| 299 | return _VSTD_LFTS_V2::get_underlying(__pt) == nullptr; |
| 300 | } |
| 301 | |
| 302 | template <class _Tp> |
| 303 | _LIBCPP_INLINE_VISIBILITY |
| 304 | _LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) |
| 305 | { |
| 306 | return nullptr == _VSTD_LFTS_V2::get_underlying(__pt); |
| 307 | } |
| 308 | |
| 309 | template <class _Tp> |
| 310 | _LIBCPP_INLINE_VISIBILITY |
| 311 | _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) |
| 312 | { |
| 313 | return _VSTD_LFTS_V2::get_underlying(__pt) != nullptr; |
| 314 | } |
| 315 | |
| 316 | template <class _Tp> |
| 317 | _LIBCPP_INLINE_VISIBILITY |
| 318 | _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) |
| 319 | { |
| 320 | return nullptr != _VSTD_LFTS_V2::get_underlying(__pt); |
| 321 | } |
| 322 | |
| 323 | template <class _Tp, class _Up> |
| 324 | _LIBCPP_INLINE_VISIBILITY |
| 325 | _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, |
| 326 | const propagate_const<_Up>& __pu) |
| 327 | { |
| 328 | return _VSTD_LFTS_V2::get_underlying(__pt) == _VSTD_LFTS_V2::get_underlying(__pu); |
| 329 | } |
| 330 | |
| 331 | template <class _Tp, class _Up> |
| 332 | _LIBCPP_INLINE_VISIBILITY |
| 333 | _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, |
| 334 | const propagate_const<_Up>& __pu) |
| 335 | { |
| 336 | return _VSTD_LFTS_V2::get_underlying(__pt) != _VSTD_LFTS_V2::get_underlying(__pu); |
| 337 | } |
| 338 | |
| 339 | template <class _Tp, class _Up> |
| 340 | _LIBCPP_INLINE_VISIBILITY |
| 341 | _LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, |
| 342 | const propagate_const<_Up>& __pu) |
| 343 | { |
| 344 | return _VSTD_LFTS_V2::get_underlying(__pt) < _VSTD_LFTS_V2::get_underlying(__pu); |
| 345 | } |
| 346 | |
| 347 | template <class _Tp, class _Up> |
| 348 | _LIBCPP_INLINE_VISIBILITY |
| 349 | _LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, |
| 350 | const propagate_const<_Up>& __pu) |
| 351 | { |
| 352 | return _VSTD_LFTS_V2::get_underlying(__pt) > _VSTD_LFTS_V2::get_underlying(__pu); |
| 353 | } |
| 354 | |
| 355 | template <class _Tp, class _Up> |
| 356 | _LIBCPP_INLINE_VISIBILITY |
| 357 | _LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, |
| 358 | const propagate_const<_Up>& __pu) |
| 359 | { |
| 360 | return _VSTD_LFTS_V2::get_underlying(__pt) <= _VSTD_LFTS_V2::get_underlying(__pu); |
| 361 | } |
| 362 | |
| 363 | template <class _Tp, class _Up> |
| 364 | _LIBCPP_INLINE_VISIBILITY |
| 365 | _LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, |
| 366 | const propagate_const<_Up>& __pu) |
| 367 | { |
| 368 | return _VSTD_LFTS_V2::get_underlying(__pt) >= _VSTD_LFTS_V2::get_underlying(__pu); |
| 369 | } |
| 370 | |
| 371 | template <class _Tp, class _Up> |
| 372 | _LIBCPP_INLINE_VISIBILITY |
| 373 | _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) |
| 374 | { |
| 375 | return _VSTD_LFTS_V2::get_underlying(__pt) == __u; |
| 376 | } |
| 377 | |
| 378 | template <class _Tp, class _Up> |
| 379 | _LIBCPP_INLINE_VISIBILITY |
| 380 | _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) |
| 381 | { |
| 382 | return _VSTD_LFTS_V2::get_underlying(__pt) != __u; |
| 383 | } |
| 384 | |
| 385 | template <class _Tp, class _Up> |
| 386 | _LIBCPP_INLINE_VISIBILITY |
| 387 | _LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) |
| 388 | { |
| 389 | return _VSTD_LFTS_V2::get_underlying(__pt) < __u; |
| 390 | } |
| 391 | |
| 392 | template <class _Tp, class _Up> |
| 393 | _LIBCPP_INLINE_VISIBILITY |
| 394 | _LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) |
| 395 | { |
| 396 | return _VSTD_LFTS_V2::get_underlying(__pt) > __u; |
| 397 | } |
| 398 | |
| 399 | template <class _Tp, class _Up> |
| 400 | _LIBCPP_INLINE_VISIBILITY |
| 401 | _LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) |
| 402 | { |
| 403 | return _VSTD_LFTS_V2::get_underlying(__pt) <= __u; |
| 404 | } |
| 405 | |
| 406 | template <class _Tp, class _Up> |
| 407 | _LIBCPP_INLINE_VISIBILITY |
| 408 | _LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) |
| 409 | { |
| 410 | return _VSTD_LFTS_V2::get_underlying(__pt) >= __u; |
| 411 | } |
| 412 | |
| 413 | |
| 414 | template <class _Tp, class _Up> |
| 415 | _LIBCPP_INLINE_VISIBILITY |
| 416 | _LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) |
| 417 | { |
| 418 | return __t == _VSTD_LFTS_V2::get_underlying(__pu); |
| 419 | } |
| 420 | |
| 421 | template <class _Tp, class _Up> |
| 422 | _LIBCPP_INLINE_VISIBILITY |
| 423 | _LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) |
| 424 | { |
| 425 | return __t != _VSTD_LFTS_V2::get_underlying(__pu); |
| 426 | } |
| 427 | |
| 428 | template <class _Tp, class _Up> |
| 429 | _LIBCPP_INLINE_VISIBILITY |
| 430 | _LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) |
| 431 | { |
| 432 | return __t < _VSTD_LFTS_V2::get_underlying(__pu); |
| 433 | } |
| 434 | |
| 435 | template <class _Tp, class _Up> |
| 436 | _LIBCPP_INLINE_VISIBILITY |
| 437 | _LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) |
| 438 | { |
| 439 | return __t > _VSTD_LFTS_V2::get_underlying(__pu); |
| 440 | } |
| 441 | |
| 442 | template <class _Tp, class _Up> |
| 443 | _LIBCPP_INLINE_VISIBILITY |
| 444 | _LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) |
| 445 | { |
| 446 | return __t <= _VSTD_LFTS_V2::get_underlying(__pu); |
| 447 | } |
| 448 | |
| 449 | template <class _Tp, class _Up> |
| 450 | _LIBCPP_INLINE_VISIBILITY |
| 451 | _LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) |
| 452 | { |
| 453 | return __t >= _VSTD_LFTS_V2::get_underlying(__pu); |
| 454 | } |
| 455 | |
| 456 | template <class _Tp> |
| 457 | _LIBCPP_INLINE_VISIBILITY |
| 458 | _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) |
| 459 | { |
| 460 | using _VSTD::swap; |
| 461 | swap(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); |
| 462 | } |
| 463 | |
| 464 | template <class _Tp> |
| 465 | _LIBCPP_INLINE_VISIBILITY |
| 466 | _LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT |
| 467 | { |
| 468 | return __pt.__t_; |
| 469 | } |
| 470 | |
| 471 | template <class _Tp> |
| 472 | _LIBCPP_INLINE_VISIBILITY |
| 473 | _LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT |
| 474 | { |
| 475 | return __pt.__t_; |
| 476 | } |
| 477 | |
| 478 | _LIBCPP_END_NAMESPACE_LFTS_V2 |
| 479 | |
| 480 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 481 | |
| 482 | template <class _Tp> |
| 483 | struct hash<experimental::fundamentals_v2::propagate_const<_Tp>> |
| 484 | { |
| 485 | typedef size_t result_type; |
| 486 | typedef experimental::fundamentals_v2::propagate_const<_Tp> argument_type; |
| 487 | |
| 488 | size_t operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1) const |
| 489 | { |
| 490 | return std::hash<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1)); |
| 491 | } |
| 492 | }; |
| 493 | |
| 494 | template <class _Tp> |
| 495 | struct equal_to<experimental::fundamentals_v2::propagate_const<_Tp>> |
| 496 | { |
| 497 | typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; |
| 498 | typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; |
| 499 | |
| 500 | bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, |
| 501 | const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const |
| 502 | { |
| 503 | return std::equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); |
| 504 | } |
| 505 | }; |
| 506 | |
| 507 | template <class _Tp> |
| 508 | struct not_equal_to<experimental::fundamentals_v2::propagate_const<_Tp>> |
| 509 | { |
| 510 | typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; |
| 511 | typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; |
| 512 | |
| 513 | bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, |
| 514 | const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const |
| 515 | { |
| 516 | return std::not_equal_to<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); |
| 517 | } |
| 518 | }; |
| 519 | |
| 520 | template <class _Tp> |
| 521 | struct less<experimental::fundamentals_v2::propagate_const<_Tp>> |
| 522 | { |
| 523 | typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; |
| 524 | typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; |
| 525 | |
| 526 | bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, |
| 527 | const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const |
| 528 | { |
| 529 | return std::less<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); |
| 530 | } |
| 531 | }; |
| 532 | |
| 533 | template <class _Tp> |
| 534 | struct greater<experimental::fundamentals_v2::propagate_const<_Tp>> |
| 535 | { |
| 536 | typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; |
| 537 | typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; |
| 538 | |
| 539 | bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, |
| 540 | const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const |
| 541 | { |
| 542 | return std::greater<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); |
| 543 | } |
| 544 | }; |
| 545 | |
| 546 | template <class _Tp> |
| 547 | struct less_equal<experimental::fundamentals_v2::propagate_const<_Tp>> |
| 548 | { |
| 549 | typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; |
| 550 | typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; |
| 551 | |
| 552 | bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, |
| 553 | const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const |
| 554 | { |
| 555 | return std::less_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); |
| 556 | } |
| 557 | }; |
| 558 | |
| 559 | template <class _Tp> |
| 560 | struct greater_equal<experimental::fundamentals_v2::propagate_const<_Tp>> |
| 561 | { |
| 562 | typedef experimental::fundamentals_v2::propagate_const<_Tp> first_argument_type; |
| 563 | typedef experimental::fundamentals_v2::propagate_const<_Tp> second_argument_type; |
| 564 | |
| 565 | bool operator()(const experimental::fundamentals_v2::propagate_const<_Tp>& __pc1, |
| 566 | const experimental::fundamentals_v2::propagate_const<_Tp>& __pc2) const |
| 567 | { |
| 568 | return std::greater_equal<_Tp>()(_VSTD_LFTS_V2::get_underlying(__pc1), _VSTD_LFTS_V2::get_underlying(__pc2)); |
| 569 | } |
| 570 | }; |
| 571 | |
| 572 | _LIBCPP_END_NAMESPACE_STD |
| 573 | |
| 574 | #endif // _LIBCPP_STD_VER > 11 |
| 575 | #endif // _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST |
| 576 | |