30#ifndef _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST
31#define _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST 1
34#pragma GCC system_header
39#if __cplusplus >= 201402L
47namespace std _GLIBCXX_VISIBILITY(default)
49_GLIBCXX_BEGIN_NAMESPACE_VERSION
53inline namespace fundamentals_v2
55 template<
typename _Tp>
56 using __propagate_const_elem_type
59 template<
typename _Tp,
60 typename _Elem = __propagate_const_elem_type<_Tp>,
61 bool = is_convertible<const _Tp, const _Elem*>::value>
62 struct __propagate_const_conversion_c
65 template<
typename _Tp,
typename _Elem>
66 struct __propagate_const_conversion_c<_Tp, _Elem, true>
68 constexpr operator const _Elem*()
const;
71 template<
typename _Tp,
72 typename _Elem = __propagate_const_elem_type<_Tp>,
73 bool = is_convertible<_Tp, _Elem*>::value>
74 struct __propagate_const_conversion_nc
77 template<
typename _Tp,
typename _Elem>
78 struct __propagate_const_conversion_nc<_Tp, _Elem, true>
80 constexpr operator _Elem*();
84 template <
typename _Tp>
85 struct __propagate_const_conversions
86 : __propagate_const_conversion_c<_Tp>, __propagate_const_conversion_nc<_Tp>
90 template<
typename _Tp>
91 struct __propagate_const_conversions<_Tp*>
93 constexpr operator const _Tp*()
const noexcept;
94 constexpr operator _Tp*()
noexcept;
109 template <
typename _Tp>
110 class propagate_const :
public __propagate_const_conversions<_Tp>
113 using element_type = __propagate_const_elem_type<_Tp>;
116 template <
typename _Up>
120 template <
typename _Up>
121 struct __is_propagate_const<propagate_const<_Up>> :
true_type
124 template <
typename _Up>
125 friend constexpr const _Up&
126 get_underlying(
const propagate_const<_Up>& __pt)
noexcept;
127 template <
typename _Up>
128 friend constexpr _Up&
129 get_underlying(propagate_const<_Up>& __pt)
noexcept;
131 template <
typename _Up>
132 static constexpr element_type*
133 __to_raw_pointer(_Up* __u)
136 template <
typename _Up>
137 static constexpr element_type*
138 __to_raw_pointer(_Up& __u)
139 {
return __u.get(); }
141 template <
typename _Up>
142 static constexpr const element_type*
143 __to_raw_pointer(
const _Up* __u)
146 template <
typename _Up>
147 static constexpr const element_type*
148 __to_raw_pointer(
const _Up& __u)
149 {
return __u.get(); }
152 static_assert(__and_<is_object<typename remove_pointer<_Tp>::type>,
153 __not_<is_array<_Tp>>,
155 "propagate_const requires a class or a pointer to an"
159 constexpr propagate_const() =
default;
160 propagate_const(
const propagate_const& __p) =
delete;
161 constexpr propagate_const(propagate_const&& __p) =
default;
163 template <
typename _Up,
typename
165 is_convertible<_Up&&, _Tp>>::value,
bool
167 constexpr propagate_const(propagate_const<_Up>&& __pu)
171 template <
typename _Up,
typename
173 __not_<is_convertible<_Up&&, _Tp>>>::value,
175 constexpr explicit propagate_const(propagate_const<_Up>&& __pu)
179 template <
typename _Up,
typename
181 is_convertible<_Up&&, _Tp>,
182 __not_<__is_propagate_const<
183 typename decay<_Up>::type>>
184 >::value,
bool>
::type=
true>
185 constexpr propagate_const(_Up&& __u)
189 template <
typename _Up,
typename
191 __not_<is_convertible<_Up&&, _Tp>>,
192 __not_<__is_propagate_const<
193 typename decay<_Up>::type>>
194 >::value,
bool>
::type=
false>
195 constexpr explicit propagate_const(_Up&& __u)
200 propagate_const& operator=(
const propagate_const& __p) =
delete;
201 constexpr propagate_const& operator=(propagate_const&& __p) =
default;
203 template <
typename _Up,
typename =
205 constexpr propagate_const& operator=(propagate_const<_Up>&& __pu)
211 template <
typename _Up,
typename =
213 __not_<__is_propagate_const<
214 typename decay<_Up>::type>>
216 constexpr propagate_const& operator=(_Up&& __u)
223 explicit constexpr operator bool()
const
228 constexpr const element_type* operator->()
const
233 constexpr const element_type& operator*()
const
238 constexpr const element_type* get()
const
240 return __to_raw_pointer(_M_t);
244 constexpr element_type* operator->()
249 constexpr element_type& operator*()
254 constexpr element_type* get()
256 return __to_raw_pointer(_M_t);
261 swap(propagate_const& __pt)
noexcept(__is_nothrow_swappable<_Tp>::value)
264 swap(_M_t, get_underlying(__pt));
272 template <
typename _Tp>
276 return get_underlying(__pt) ==
nullptr;
279 template <
typename _Tp>
283 return nullptr == get_underlying(__pu);
286 template <
typename _Tp>
288 operator!=(
const propagate_const<_Tp>& __pt, nullptr_t)
290 return get_underlying(__pt) !=
nullptr;
293 template <
typename _Tp>
294 constexpr bool operator!=(nullptr_t,
const propagate_const<_Tp>& __pu)
296 return nullptr != get_underlying(__pu);
299 template <
typename _Tp,
typename _Up>
304 return get_underlying(__pt) == get_underlying(__pu);
307 template <
typename _Tp,
typename _Up>
312 return get_underlying(__pt) != get_underlying(__pu);
315 template <
typename _Tp,
typename _Up>
320 return get_underlying(__pt) < get_underlying(__pu);
323 template <
typename _Tp,
typename _Up>
328 return get_underlying(__pt) > get_underlying(__pu);
331 template <
typename _Tp,
typename _Up>
336 return get_underlying(__pt) <= get_underlying(__pu);
339 template <
typename _Tp,
typename _Up>
344 return get_underlying(__pt) >= get_underlying(__pu);
347 template <
typename _Tp,
typename _Up>
351 return get_underlying(__pt) == __u;
354 template <
typename _Tp,
typename _Up>
358 return get_underlying(__pt) != __u;
361 template <
typename _Tp,
typename _Up>
365 return get_underlying(__pt) < __u;
368 template <
typename _Tp,
typename _Up>
372 return get_underlying(__pt) > __u;
375 template <
typename _Tp,
typename _Up>
379 return get_underlying(__pt) <= __u;
382 template <
typename _Tp,
typename _Up>
386 return get_underlying(__pt) >= __u;
389 template <
typename _Tp,
typename _Up>
393 return __t == get_underlying(__pu);
396 template <
typename _Tp,
typename _Up>
400 return __t != get_underlying(__pu);
403 template <
typename _Tp,
typename _Up>
407 return __t < get_underlying(__pu);
410 template <
typename _Tp,
typename _Up>
414 return __t > get_underlying(__pu);
417 template <
typename _Tp,
typename _Up>
421 return __t <= get_underlying(__pu);
424 template <
typename _Tp,
typename _Up>
428 return __t >= get_underlying(__pu);
434 template <
typename _Tp>
435 constexpr enable_if_t<__is_swappable<_Tp>::value,
void>
437 noexcept(__is_nothrow_swappable<_Tp>::value)
443 template <
typename _Tp>
450 template <
typename _Tp>
457 template<
typename _Tp>
459 __propagate_const_conversions<_Tp*>::operator
const _Tp*()
const noexcept
462 template<
typename _Tp>
464 __propagate_const_conversions<_Tp*>::operator _Tp*()
noexcept
467 template<
typename _Tp,
typename _Elem>
469 __propagate_const_conversion_c<_Tp, _Elem, true>::
470 operator
const _Elem*()
const
473 template<
typename _Tp,
typename _Elem>
475 __propagate_const_conversion_nc<_Tp, _Elem, true>::
484 template <
typename _Tp>
487 using result_type = size_t;
488 using argument_type = experimental::propagate_const<_Tp>;
491 operator()(
const experimental::propagate_const<_Tp>& __t)
const
492 noexcept(
noexcept(hash<_Tp>{}(get_underlying(__t))))
494 return hash<_Tp>{}(get_underlying(__t));
499 template <
typename _Tp>
503 operator()(
const experimental::propagate_const<_Tp>& __x,
504 const experimental::propagate_const<_Tp>& __y)
const
506 return equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
514 template <
typename _Tp>
518 operator()(
const experimental::propagate_const<_Tp>& __x,
519 const experimental::propagate_const<_Tp>& __y)
const
521 return not_equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
529 template <
typename _Tp>
533 operator()(
const experimental::propagate_const<_Tp>& __x,
534 const experimental::propagate_const<_Tp>& __y)
const
536 return less<_Tp>{}(get_underlying(__x), get_underlying(__y));
544 template <
typename _Tp>
548 operator()(
const experimental::propagate_const<_Tp>& __x,
549 const experimental::propagate_const<_Tp>& __y)
const
551 return greater<_Tp>{}(get_underlying(__x), get_underlying(__y));
559 template <
typename _Tp>
563 operator()(
const experimental::propagate_const<_Tp>& __x,
564 const experimental::propagate_const<_Tp>& __y)
const
566 return less_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
574 template <
typename _Tp>
578 operator()(
const experimental::propagate_const<_Tp>& __x,
579 const experimental::propagate_const<_Tp>& __y)
const
581 return greater_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
589_GLIBCXX_END_NAMESPACE_VERSION
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
ISO C++ entities toplevel namespace is std.
Namespace for features defined in ISO Technical Specifications.
Primary class template hash.
Define a member typedef type only if a boolean constant is true.
One of the comparison functors.
One of the comparison functors.
One of the comparison functors.
One of the comparison functors.
One of the comparison functors.
One of the comparison functors.
Const-propagating wrapper.