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;
116 template <
typename _Up,
typename
123 template <
typename _Up,
typename
125 __not_<is_convertible<_Up&&, _Tp>>>::value,
130 template <
typename _Up,
typename
133 __not_<__is_propagate_const<
134 typename decay<_Up>::type>>
135 >::value,
bool>::type=
true>
136 constexpr propagate_const(_Up&& __u)
137 : _M_t(std::forward<_Up>(__u))
139 template <
typename _Up,
typename
141 __not_<is_convertible<_Up&&, _Tp>>,
142 __not_<__is_propagate_const<
143 typename decay<_Up>::type>>
144 >::value,
bool>::type=
false>
145 constexpr
explicit propagate_const(_Up&& __u)
146 : _M_t(std::forward<_Up>(__u))
150 propagate_const& operator=(
const propagate_const& __p) =
delete;
151 constexpr propagate_const& operator=(propagate_const&& __p) =
default;
153 template <
typename _Up,
typename =
161 template <
typename _Up,
typename =
163 __not_<__is_propagate_const<
164 typename decay<_Up>::type>>
166 constexpr propagate_const& operator=(_Up&& __u)
168 _M_t = std::forward<_Up>(__u);
173 explicit constexpr
operator bool()
const
178 constexpr
const element_type* operator->()
const
183 template <
typename _Up = _Tp,
187 >::value,
bool>::type =
true>
188 constexpr
operator const element_type*()
const
193 constexpr
const element_type& operator*()
const
198 constexpr
const element_type*
get()
const
200 return __to_raw_pointer(_M_t);
204 constexpr element_type* operator->()
209 template <
typename _Up = _Tp,
213 >::value,
bool>::type =
true>
214 constexpr
operator element_type*()
219 constexpr element_type& operator*()
224 constexpr element_type*
get()
226 return __to_raw_pointer(_M_t);
231 swap(propagate_const& __pt) noexcept(__is_nothrow_swappable<_Tp>::value)
234 swap(_M_t, get_underlying(__pt));
242 template <
typename _Tp>
246 return get_underlying(__pt) ==
nullptr;
249 template <
typename _Tp>
251 operator==(nullptr_t,
const propagate_const<_Tp>& __pu)
253 return nullptr == get_underlying(__pu);
256 template <
typename _Tp>
258 operator!=(
const propagate_const<_Tp>& __pt, nullptr_t)
260 return get_underlying(__pt) !=
nullptr;
263 template <
typename _Tp>
264 constexpr
bool operator!=(nullptr_t,
const propagate_const<_Tp>& __pu)
266 return nullptr != get_underlying(__pu);
269 template <
typename _Tp,
typename _Up>
271 operator==(
const propagate_const<_Tp>& __pt,
272 const propagate_const<_Up>& __pu)
274 return get_underlying(__pt) == get_underlying(__pu);
277 template <
typename _Tp,
typename _Up>
279 operator!=(
const propagate_const<_Tp>& __pt,
280 const propagate_const<_Up>& __pu)
282 return get_underlying(__pt) != get_underlying(__pu);
285 template <
typename _Tp,
typename _Up>
287 operator<(const propagate_const<_Tp>& __pt,
288 const propagate_const<_Up>& __pu)
290 return get_underlying(__pt) < get_underlying(__pu);
293 template <
typename _Tp,
typename _Up>
295 operator>(
const propagate_const<_Tp>& __pt,
296 const propagate_const<_Up>& __pu)
298 return get_underlying(__pt) > get_underlying(__pu);
301 template <
typename _Tp,
typename _Up>
303 operator<=(const propagate_const<_Tp>& __pt,
304 const propagate_const<_Up>& __pu)
306 return get_underlying(__pt) <= get_underlying(__pu);
309 template <
typename _Tp,
typename _Up>
311 operator>=(
const propagate_const<_Tp>& __pt,
312 const propagate_const<_Up>& __pu)
314 return get_underlying(__pt) >= get_underlying(__pu);
317 template <
typename _Tp,
typename _Up>
319 operator==(
const propagate_const<_Tp>& __pt,
const _Up& __u)
321 return get_underlying(__pt) == __u;
324 template <
typename _Tp,
typename _Up>
326 operator!=(
const propagate_const<_Tp>& __pt,
const _Up& __u)
328 return get_underlying(__pt) != __u;
331 template <
typename _Tp,
typename _Up>
333 operator<(const propagate_const<_Tp>& __pt,
const _Up& __u)
335 return get_underlying(__pt) < __u;
338 template <
typename _Tp,
typename _Up>
340 operator>(
const propagate_const<_Tp>& __pt,
const _Up& __u)
342 return get_underlying(__pt) > __u;
345 template <
typename _Tp,
typename _Up>
347 operator<=(const propagate_const<_Tp>& __pt,
const _Up& __u)
349 return get_underlying(__pt) <= __u;
352 template <
typename _Tp,
typename _Up>
354 operator>=(
const propagate_const<_Tp>& __pt,
const _Up& __u)
356 return get_underlying(__pt) >= __u;
359 template <
typename _Tp,
typename _Up>
361 operator==(
const _Tp& __t,
const propagate_const<_Up>& __pu)
363 return __t == get_underlying(__pu);
366 template <
typename _Tp,
typename _Up>
368 operator!=(
const _Tp& __t,
const propagate_const<_Up>& __pu)
370 return __t != get_underlying(__pu);
373 template <
typename _Tp,
typename _Up>
375 operator<(const _Tp& __t, const propagate_const<_Up>& __pu)
377 return __t < get_underlying(__pu);
380 template <
typename _Tp,
typename _Up>
382 operator>(
const _Tp& __t,
const propagate_const<_Up>& __pu)
384 return __t > get_underlying(__pu);
387 template <
typename _Tp,
typename _Up>
389 operator<=(const _Tp& __t, const propagate_const<_Up>& __pu)
391 return __t <= get_underlying(__pu);
394 template <
typename _Tp,
typename _Up>
396 operator>=(
const _Tp& __t,
const propagate_const<_Up>& __pu)
398 return __t >= get_underlying(__pu);
402 template <
typename _Tp>
404 swap(propagate_const<_Tp>& __pt, propagate_const<_Tp>& __pt2)
405 noexcept(__is_nothrow_swappable<_Tp>::value)
411 template <
typename _Tp>
413 get_underlying(
const propagate_const<_Tp>& __pt) noexcept
418 template <
typename _Tp>
420 get_underlying(propagate_const<_Tp>& __pt) noexcept
430 template <
typename _Tp>
431 struct hash<experimental::propagate_const<_Tp>>
433 using result_type = size_t;
434 using argument_type = experimental::propagate_const<_Tp>;
437 operator()(
const experimental::propagate_const<_Tp>& __t)
const
438 noexcept(noexcept(hash<_Tp>{}(get_underlying(__t))))
440 return hash<_Tp>{}(get_underlying(__t));
445 template <
typename _Tp>
446 struct equal_to<experimental::propagate_const<_Tp>>
449 operator()(
const experimental::propagate_const<_Tp>& __x,
450 const experimental::propagate_const<_Tp>& __y)
const
452 return equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
460 template <
typename _Tp>
461 struct not_equal_to<experimental::propagate_const<_Tp>>
464 operator()(
const experimental::propagate_const<_Tp>& __x,
465 const experimental::propagate_const<_Tp>& __y)
const
467 return not_equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
475 template <
typename _Tp>
476 struct less<experimental::propagate_const<_Tp>>
479 operator()(
const experimental::propagate_const<_Tp>& __x,
480 const experimental::propagate_const<_Tp>& __y)
const
482 return less<_Tp>{}(get_underlying(__x), get_underlying(__y));
490 template <
typename _Tp>
491 struct greater<experimental::propagate_const<_Tp>>
494 operator()(
const experimental::propagate_const<_Tp>& __x,
495 const experimental::propagate_const<_Tp>& __y)
const
497 return greater<_Tp>{}(get_underlying(__x), get_underlying(__y));
505 template <
typename _Tp>
506 struct less_equal<experimental::propagate_const<_Tp>>
509 operator()(
const experimental::propagate_const<_Tp>& __x,
510 const experimental::propagate_const<_Tp>& __y)
const
512 return less_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
520 template <
typename _Tp>
521 struct greater_equal<experimental::propagate_const<_Tp>>
524 operator()(
const experimental::propagate_const<_Tp>& __x,
525 const experimental::propagate_const<_Tp>& __y)
const
527 return greater_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
535 _GLIBCXX_END_NAMESPACE_VERSION
540 #endif // _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST
Define a member typedef type only if a boolean constant is true.
Const-propagating wrapper.
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
bool result_type
result_type is the return type
_Tp first_argument_type
first_argument_type is the type of the first argument
_Tp second_argument_type
second_argument_type is the type of the second argument
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.