30 #ifndef _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST 31 #define _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST 1 33 #ifdef _GLIBCXX_SYSHDR 34 #pragma GCC system_header 39 #if __cplusplus >= 201402L 47 namespace std _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
51 namespace experimental
53 inline namespace fundamentals_v2
55 template<
typename _Tp>
56 using __propagate_const_elem_type
57 = remove_reference_t<decltype(*std::declval<_Tp&>())>;
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>
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&
127 template <
typename _Up>
128 friend constexpr _Up&
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>,
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 171 template <
typename _Up,
typename 172 enable_if<__and_<is_constructible<_Tp, _Up&&>,
173 __not_<is_convertible<_Up&&, _Tp>>>::value,
179 template <
typename _Up,
typename 180 enable_if<__and_<is_constructible<_Tp, _Up&&>,
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)
186 : _M_t(std::forward<_Up>(__u))
189 template <
typename _Up,
typename 190 enable_if<__and_<is_constructible<_Tp, _Up&&>,
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)
196 : _M_t(std::forward<_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 =
211 template <
typename _Up,
typename =
213 __not_<__is_propagate_const<
214 typename decay<_Up>::type>>
216 constexpr propagate_const& operator=(_Up&& __u)
218 _M_t = std::forward<_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->()
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>
290 return get_underlying(__pt) !=
nullptr;
293 template <
typename _Tp>
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>
317 operator<(const propagate_const<_Tp>& __pt,
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>
333 operator<=(const propagate_const<_Tp>& __pt,
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>
363 operator<(const propagate_const<_Tp>& __pt,
const _Up& __u)
365 return get_underlying(__pt) < __u;
368 template <
typename _Tp,
typename _Up>
372 return get_underlying(__pt) > __u;
375 template <
typename _Tp,
typename _Up>
377 operator<=(const propagate_const<_Tp>& __pt,
const _Up& __u)
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>
405 operator<(const _Tp& __t, const propagate_const<_Up>& __pu)
407 return __t < get_underlying(__pu);
410 template <
typename _Tp,
typename _Up>
414 return __t > get_underlying(__pu);
417 template <
typename _Tp,
typename _Up>
419 operator<=(const _Tp& __t, const propagate_const<_Up>& __pu)
421 return __t <= get_underlying(__pu);
424 template <
typename _Tp,
typename _Up>
428 return __t >= get_underlying(__pu);
434 template <
typename _Tp>
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))))
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));
509 typedef experimental::propagate_const<_Tp> first_argument_type;
510 typedef experimental::propagate_const<_Tp> second_argument_type;
511 typedef bool result_type;
514 template <
typename _Tp>
518 operator()(
const experimental::propagate_const<_Tp>& __x,
519 const experimental::propagate_const<_Tp>& __y)
const 524 typedef experimental::propagate_const<_Tp> first_argument_type;
525 typedef experimental::propagate_const<_Tp> second_argument_type;
526 typedef bool result_type;
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));
539 typedef experimental::propagate_const<_Tp> first_argument_type;
540 typedef experimental::propagate_const<_Tp> second_argument_type;
541 typedef bool result_type;
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));
554 typedef experimental::propagate_const<_Tp> first_argument_type;
555 typedef experimental::propagate_const<_Tp> second_argument_type;
556 typedef bool result_type;
559 template <
typename _Tp>
563 operator()(
const experimental::propagate_const<_Tp>& __x,
564 const experimental::propagate_const<_Tp>& __y)
const 569 typedef experimental::propagate_const<_Tp> first_argument_type;
570 typedef experimental::propagate_const<_Tp> second_argument_type;
571 typedef bool result_type;
574 template <
typename _Tp>
578 operator()(
const experimental::propagate_const<_Tp>& __x,
579 const experimental::propagate_const<_Tp>& __y)
const 584 typedef experimental::propagate_const<_Tp> first_argument_type;
585 typedef experimental::propagate_const<_Tp> second_argument_type;
586 typedef bool result_type;
589 _GLIBCXX_END_NAMESPACE_VERSION
594 #endif // _GLIBCXX_EXPERIMENTAL_PROPAGATE_CONST
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
One of the comparison functors.
__bool_constant< true > true_type
The type used as a compile-time boolean with true value.
One of the comparison functors.
Const-propagating wrapper.
ISO C++ entities toplevel namespace is std.
One of the comparison functors.
__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.
One of the comparison functors.
Define a member typedef type only if a boolean constant is true.
Primary class template hash.
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
One of the comparison functors.
One of the comparison functors.