30 #ifndef _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST
31 #define _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST 1
33 #pragma GCC system_header
35 #if __cplusplus >= 201402L
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
47 namespace experimental
49 inline namespace fundamentals_v2
63 template <
typename _Tp>
70 template <
typename _Up>
74 template <
typename _Up>
75 struct __is_propagate_const<propagate_const<_Up>> :
true_type
78 template <
typename _Up>
79 friend constexpr
const _Up&
81 template <
typename _Up>
85 template <
typename _Up>
86 static constexpr element_type*
87 __to_raw_pointer(_Up* __u)
90 template <
typename _Up>
91 static constexpr element_type*
92 __to_raw_pointer(_Up& __u)
95 template <
typename _Up>
96 static constexpr
const element_type*
97 __to_raw_pointer(
const _Up* __u)
100 template <
typename _Up>
101 static constexpr
const element_type*
102 __to_raw_pointer(
const _Up& __u)
103 {
return __u.get(); }
106 static_assert(__and_<
is_object<
typename remove_pointer<_Tp>::type>,
109 "propagate_const requires a class or a pointer to an"
113 constexpr propagate_const() =
default;
114 propagate_const(
const propagate_const& __p) =
delete;
115 constexpr propagate_const(propagate_const&& __p) =
default;
117 template <
typename _Up,
typename
125 template <
typename _Up,
typename
127 __not_<is_convertible<_Up&&, _Tp>>>::value,
133 template <
typename _Up,
typename
136 __not_<__is_propagate_const<
137 typename decay<_Up>::type>>
138 >::value,
bool>::type=
true>
139 constexpr propagate_const(_Up&& __u)
140 : _M_t(std::forward<_Up>(__u))
143 template <
typename _Up,
typename
145 __not_<is_convertible<_Up&&, _Tp>>,
146 __not_<__is_propagate_const<
147 typename decay<_Up>::type>>
148 >::value,
bool>::type=
false>
149 constexpr
explicit propagate_const(_Up&& __u)
150 : _M_t(std::forward<_Up>(__u))
154 propagate_const& operator=(
const propagate_const& __p) =
delete;
155 constexpr propagate_const& operator=(propagate_const&& __p) =
default;
157 template <
typename _Up,
typename =
165 template <
typename _Up,
typename =
167 __not_<__is_propagate_const<
168 typename decay<_Up>::type>>
170 constexpr propagate_const& operator=(_Up&& __u)
172 _M_t = std::forward<_Up>(__u);
177 explicit constexpr
operator bool()
const
182 constexpr
const element_type* operator->()
const
187 template <
typename _Up = _Tp,
191 >::value,
bool>::type =
true>
192 constexpr
operator const element_type*()
const
197 constexpr
const element_type& operator*()
const
202 constexpr
const element_type*
get()
const
204 return __to_raw_pointer(_M_t);
208 constexpr element_type* operator->()
213 template <
typename _Up = _Tp,
217 >::value,
bool>::type =
true>
218 constexpr
operator element_type*()
223 constexpr element_type& operator*()
228 constexpr element_type*
get()
230 return __to_raw_pointer(_M_t);
235 swap(propagate_const& __pt) noexcept(__is_nothrow_swappable<_Tp>::value)
238 swap(_M_t, get_underlying(__pt));
246 template <
typename _Tp>
250 return get_underlying(__pt) ==
nullptr;
253 template <
typename _Tp>
255 operator==(nullptr_t,
const propagate_const<_Tp>& __pu)
257 return nullptr == get_underlying(__pu);
260 template <
typename _Tp>
262 operator!=(
const propagate_const<_Tp>& __pt, nullptr_t)
264 return get_underlying(__pt) !=
nullptr;
267 template <
typename _Tp>
268 constexpr
bool operator!=(nullptr_t,
const propagate_const<_Tp>& __pu)
270 return nullptr != get_underlying(__pu);
273 template <
typename _Tp,
typename _Up>
275 operator==(
const propagate_const<_Tp>& __pt,
276 const propagate_const<_Up>& __pu)
278 return get_underlying(__pt) == get_underlying(__pu);
281 template <
typename _Tp,
typename _Up>
283 operator!=(
const propagate_const<_Tp>& __pt,
284 const propagate_const<_Up>& __pu)
286 return get_underlying(__pt) != get_underlying(__pu);
289 template <
typename _Tp,
typename _Up>
291 operator<(const propagate_const<_Tp>& __pt,
292 const propagate_const<_Up>& __pu)
294 return get_underlying(__pt) < get_underlying(__pu);
297 template <
typename _Tp,
typename _Up>
299 operator>(
const propagate_const<_Tp>& __pt,
300 const propagate_const<_Up>& __pu)
302 return get_underlying(__pt) > get_underlying(__pu);
305 template <
typename _Tp,
typename _Up>
307 operator<=(const propagate_const<_Tp>& __pt,
308 const propagate_const<_Up>& __pu)
310 return get_underlying(__pt) <= get_underlying(__pu);
313 template <
typename _Tp,
typename _Up>
315 operator>=(
const propagate_const<_Tp>& __pt,
316 const propagate_const<_Up>& __pu)
318 return get_underlying(__pt) >= get_underlying(__pu);
321 template <
typename _Tp,
typename _Up>
323 operator==(
const propagate_const<_Tp>& __pt,
const _Up& __u)
325 return get_underlying(__pt) == __u;
328 template <
typename _Tp,
typename _Up>
330 operator!=(
const propagate_const<_Tp>& __pt,
const _Up& __u)
332 return get_underlying(__pt) != __u;
335 template <
typename _Tp,
typename _Up>
337 operator<(const propagate_const<_Tp>& __pt,
const _Up& __u)
339 return get_underlying(__pt) < __u;
342 template <
typename _Tp,
typename _Up>
344 operator>(
const propagate_const<_Tp>& __pt,
const _Up& __u)
346 return get_underlying(__pt) > __u;
349 template <
typename _Tp,
typename _Up>
351 operator<=(const propagate_const<_Tp>& __pt,
const _Up& __u)
353 return get_underlying(__pt) <= __u;
356 template <
typename _Tp,
typename _Up>
358 operator>=(
const propagate_const<_Tp>& __pt,
const _Up& __u)
360 return get_underlying(__pt) >= __u;
363 template <
typename _Tp,
typename _Up>
365 operator==(
const _Tp& __t,
const propagate_const<_Up>& __pu)
367 return __t == get_underlying(__pu);
370 template <
typename _Tp,
typename _Up>
372 operator!=(
const _Tp& __t,
const propagate_const<_Up>& __pu)
374 return __t != get_underlying(__pu);
377 template <
typename _Tp,
typename _Up>
379 operator<(const _Tp& __t, const propagate_const<_Up>& __pu)
381 return __t < get_underlying(__pu);
384 template <
typename _Tp,
typename _Up>
386 operator>(
const _Tp& __t,
const propagate_const<_Up>& __pu)
388 return __t > get_underlying(__pu);
391 template <
typename _Tp,
typename _Up>
393 operator<=(const _Tp& __t, const propagate_const<_Up>& __pu)
395 return __t <= get_underlying(__pu);
398 template <
typename _Tp,
typename _Up>
400 operator>=(
const _Tp& __t,
const propagate_const<_Up>& __pu)
402 return __t >= get_underlying(__pu);
408 template <
typename _Tp>
409 constexpr enable_if_t<__is_swappable<_Tp>::value,
void>
410 swap(propagate_const<_Tp>& __pt, propagate_const<_Tp>& __pt2)
411 noexcept(__is_nothrow_swappable<_Tp>::value)
417 template <
typename _Tp>
419 get_underlying(
const propagate_const<_Tp>& __pt) noexcept
424 template <
typename _Tp>
426 get_underlying(propagate_const<_Tp>& __pt) noexcept
436 template <
typename _Tp>
437 struct hash<experimental::propagate_const<_Tp>>
439 using result_type = size_t;
440 using argument_type = experimental::propagate_const<_Tp>;
443 operator()(
const experimental::propagate_const<_Tp>& __t)
const
444 noexcept(noexcept(hash<_Tp>{}(get_underlying(__t))))
446 return hash<_Tp>{}(get_underlying(__t));
451 template <
typename _Tp>
452 struct equal_to<experimental::propagate_const<_Tp>>
455 operator()(
const experimental::propagate_const<_Tp>& __x,
456 const experimental::propagate_const<_Tp>& __y)
const
458 return equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
466 template <
typename _Tp>
467 struct not_equal_to<experimental::propagate_const<_Tp>>
470 operator()(
const experimental::propagate_const<_Tp>& __x,
471 const experimental::propagate_const<_Tp>& __y)
const
473 return not_equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
481 template <
typename _Tp>
482 struct less<experimental::propagate_const<_Tp>>
485 operator()(
const experimental::propagate_const<_Tp>& __x,
486 const experimental::propagate_const<_Tp>& __y)
const
488 return less<_Tp>{}(get_underlying(__x), get_underlying(__y));
496 template <
typename _Tp>
497 struct greater<experimental::propagate_const<_Tp>>
500 operator()(
const experimental::propagate_const<_Tp>& __x,
501 const experimental::propagate_const<_Tp>& __y)
const
503 return greater<_Tp>{}(get_underlying(__x), get_underlying(__y));
511 template <
typename _Tp>
512 struct less_equal<experimental::propagate_const<_Tp>>
515 operator()(
const experimental::propagate_const<_Tp>& __x,
516 const experimental::propagate_const<_Tp>& __y)
const
518 return less_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
526 template <
typename _Tp>
527 struct greater_equal<experimental::propagate_const<_Tp>>
530 operator()(
const experimental::propagate_const<_Tp>& __x,
531 const experimental::propagate_const<_Tp>& __y)
const
533 return greater_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
541 _GLIBCXX_END_NAMESPACE_VERSION
546 #endif // _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
Const-propagating wrapper.
bool result_type
result_type is the return type
_Tp first_argument_type
first_argument_type is the type of the first argument
Define a member typedef type only if a boolean constant is true.
_Tp second_argument_type
second_argument_type is the type of the second argument
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.