30#ifndef _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST
31#define _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST 1
33#pragma GCC system_header
37#if __cplusplus >= 201402L
45namespace std _GLIBCXX_VISIBILITY(default)
47_GLIBCXX_BEGIN_NAMESPACE_VERSION
51inline namespace fundamentals_v2
53 template<
typename _Tp>
54 using __propagate_const_elem_type
57 template<
typename _Tp,
58 typename _Elem = __propagate_const_elem_type<_Tp>,
59 bool = is_convertible<const _Tp, const _Elem*>::value>
60 struct __propagate_const_conversion_c
63 template<
typename _Tp,
typename _Elem>
64 struct __propagate_const_conversion_c<_Tp, _Elem, true>
66 constexpr operator const _Elem*()
const;
69 template<
typename _Tp,
70 typename _Elem = __propagate_const_elem_type<_Tp>,
71 bool = is_convertible<_Tp, _Elem*>::value>
72 struct __propagate_const_conversion_nc
75 template<
typename _Tp,
typename _Elem>
76 struct __propagate_const_conversion_nc<_Tp, _Elem, true>
78 constexpr operator _Elem*();
82 template <
typename _Tp>
83 struct __propagate_const_conversions
84 : __propagate_const_conversion_c<_Tp>, __propagate_const_conversion_nc<_Tp>
88 template<
typename _Tp>
89 struct __propagate_const_conversions<_Tp*>
91 constexpr operator const _Tp*()
const noexcept;
92 constexpr operator _Tp*()
noexcept;
107 template <
typename _Tp>
108 class propagate_const :
public __propagate_const_conversions<_Tp>
111 using element_type = __propagate_const_elem_type<_Tp>;
114 template <
typename _Up>
118 template <
typename _Up>
119 struct __is_propagate_const<propagate_const<_Up>> :
true_type
122 template <
typename _Up>
123 friend constexpr const _Up&
124 get_underlying(
const propagate_const<_Up>& __pt)
noexcept;
125 template <
typename _Up>
126 friend constexpr _Up&
127 get_underlying(propagate_const<_Up>& __pt)
noexcept;
129 template <
typename _Up>
130 static constexpr element_type*
131 __to_raw_pointer(_Up* __u)
134 template <
typename _Up>
135 static constexpr element_type*
136 __to_raw_pointer(_Up& __u)
137 {
return __u.get(); }
139 template <
typename _Up>
140 static constexpr const element_type*
141 __to_raw_pointer(
const _Up* __u)
144 template <
typename _Up>
145 static constexpr const element_type*
146 __to_raw_pointer(
const _Up& __u)
147 {
return __u.get(); }
150 static_assert(__and_<is_object<typename remove_pointer<_Tp>::type>,
151 __not_<is_array<_Tp>>,
153 "propagate_const requires a class or a pointer to an"
157 constexpr propagate_const() =
default;
158 propagate_const(
const propagate_const& __p) =
delete;
159 constexpr propagate_const(propagate_const&& __p) =
default;
161 template <
typename _Up,
typename
163 is_convertible<_Up&&, _Tp>>::value,
bool
165 constexpr propagate_const(propagate_const<_Up>&& __pu)
169 template <
typename _Up,
typename
171 __not_<is_convertible<_Up&&, _Tp>>>::value,
173 constexpr explicit propagate_const(propagate_const<_Up>&& __pu)
177 template <
typename _Up,
typename
179 is_convertible<_Up&&, _Tp>,
180 __not_<__is_propagate_const<
181 typename decay<_Up>::type>>
182 >::value,
bool>
::type=
true>
183 constexpr propagate_const(_Up&& __u)
187 template <
typename _Up,
typename
189 __not_<is_convertible<_Up&&, _Tp>>,
190 __not_<__is_propagate_const<
191 typename decay<_Up>::type>>
192 >::value,
bool>
::type=
false>
193 constexpr explicit propagate_const(_Up&& __u)
198 propagate_const& operator=(
const propagate_const& __p) =
delete;
199 constexpr propagate_const& operator=(propagate_const&& __p) =
default;
201 template <
typename _Up,
typename =
203 constexpr propagate_const& operator=(propagate_const<_Up>&& __pu)
209 template <
typename _Up,
typename =
211 __not_<__is_propagate_const<
212 typename decay<_Up>::type>>
214 constexpr propagate_const& operator=(_Up&& __u)
221 explicit constexpr operator bool()
const
226 constexpr const element_type* operator->()
const
231 constexpr const element_type& operator*()
const
236 constexpr const element_type* get()
const
238 return __to_raw_pointer(_M_t);
242 constexpr element_type* operator->()
247 constexpr element_type& operator*()
252 constexpr element_type* get()
254 return __to_raw_pointer(_M_t);
259 swap(propagate_const& __pt)
noexcept(__is_nothrow_swappable<_Tp>::value)
262 swap(_M_t, get_underlying(__pt));
270 template <
typename _Tp>
274 return get_underlying(__pt) ==
nullptr;
277 template <
typename _Tp>
281 return nullptr == get_underlying(__pu);
284 template <
typename _Tp>
286 operator!=(
const propagate_const<_Tp>& __pt, nullptr_t)
288 return get_underlying(__pt) !=
nullptr;
291 template <
typename _Tp>
292 constexpr bool operator!=(nullptr_t,
const propagate_const<_Tp>& __pu)
294 return nullptr != get_underlying(__pu);
297 template <
typename _Tp,
typename _Up>
302 return get_underlying(__pt) == get_underlying(__pu);
305 template <
typename _Tp,
typename _Up>
310 return get_underlying(__pt) != get_underlying(__pu);
313 template <
typename _Tp,
typename _Up>
318 return get_underlying(__pt) < get_underlying(__pu);
321 template <
typename _Tp,
typename _Up>
326 return get_underlying(__pt) > get_underlying(__pu);
329 template <
typename _Tp,
typename _Up>
334 return get_underlying(__pt) <= get_underlying(__pu);
337 template <
typename _Tp,
typename _Up>
342 return get_underlying(__pt) >= get_underlying(__pu);
345 template <
typename _Tp,
typename _Up>
349 return get_underlying(__pt) == __u;
352 template <
typename _Tp,
typename _Up>
356 return get_underlying(__pt) != __u;
359 template <
typename _Tp,
typename _Up>
363 return get_underlying(__pt) < __u;
366 template <
typename _Tp,
typename _Up>
370 return get_underlying(__pt) > __u;
373 template <
typename _Tp,
typename _Up>
377 return get_underlying(__pt) <= __u;
380 template <
typename _Tp,
typename _Up>
384 return get_underlying(__pt) >= __u;
387 template <
typename _Tp,
typename _Up>
391 return __t == get_underlying(__pu);
394 template <
typename _Tp,
typename _Up>
398 return __t != get_underlying(__pu);
401 template <
typename _Tp,
typename _Up>
405 return __t < get_underlying(__pu);
408 template <
typename _Tp,
typename _Up>
412 return __t > get_underlying(__pu);
415 template <
typename _Tp,
typename _Up>
419 return __t <= get_underlying(__pu);
422 template <
typename _Tp,
typename _Up>
426 return __t >= get_underlying(__pu);
432 template <
typename _Tp>
433 constexpr enable_if_t<__is_swappable<_Tp>::value,
void>
435 noexcept(__is_nothrow_swappable<_Tp>::value)
441 template <
typename _Tp>
448 template <
typename _Tp>
455 template<
typename _Tp>
457 __propagate_const_conversions<_Tp*>::operator
const _Tp*()
const noexcept
460 template<
typename _Tp>
462 __propagate_const_conversions<_Tp*>::operator _Tp*()
noexcept
465 template<
typename _Tp,
typename _Elem>
467 __propagate_const_conversion_c<_Tp, _Elem, true>::
468 operator
const _Elem*()
const
471 template<
typename _Tp,
typename _Elem>
473 __propagate_const_conversion_nc<_Tp, _Elem, true>::
482 template <
typename _Tp>
485 using result_type = size_t;
486 using argument_type = experimental::propagate_const<_Tp>;
489 operator()(
const experimental::propagate_const<_Tp>& __t)
const
490 noexcept(
noexcept(hash<_Tp>{}(get_underlying(__t))))
492 return hash<_Tp>{}(get_underlying(__t));
497 template <
typename _Tp>
501 operator()(
const experimental::propagate_const<_Tp>& __x,
502 const experimental::propagate_const<_Tp>& __y)
const
504 return equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
512 template <
typename _Tp>
516 operator()(
const experimental::propagate_const<_Tp>& __x,
517 const experimental::propagate_const<_Tp>& __y)
const
519 return not_equal_to<_Tp>{}(get_underlying(__x), get_underlying(__y));
527 template <
typename _Tp>
531 operator()(
const experimental::propagate_const<_Tp>& __x,
532 const experimental::propagate_const<_Tp>& __y)
const
534 return less<_Tp>{}(get_underlying(__x), get_underlying(__y));
542 template <
typename _Tp>
546 operator()(
const experimental::propagate_const<_Tp>& __x,
547 const experimental::propagate_const<_Tp>& __y)
const
549 return greater<_Tp>{}(get_underlying(__x), get_underlying(__y));
557 template <
typename _Tp>
561 operator()(
const experimental::propagate_const<_Tp>& __x,
562 const experimental::propagate_const<_Tp>& __y)
const
564 return less_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
572 template <
typename _Tp>
576 operator()(
const experimental::propagate_const<_Tp>& __x,
577 const experimental::propagate_const<_Tp>& __y)
const
579 return greater_equal<_Tp>{}(get_underlying(__x), get_underlying(__y));
587_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.