39 #pragma GCC system_header
45 #if __cplusplus >= 201103L
49 #if __cplusplus > 201703L
53 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
55 _GLIBCXX_BEGIN_NAMESPACE_VERSION
68 template<
typename _Tp>
73 typedef _Tp element_type;
82 set(element_type* __arg)
88 {
return (_M_value < __rarg._M_value); }
92 {
return (_M_value == __rarg._M_value); }
95 element_type* _M_value;
111 template<
typename _Tp>
115 typedef _Tp element_type;
123 return reinterpret_cast<_Tp*
>(
reinterpret_cast<_UIntPtrType
>(
this)
133 _M_diff =
reinterpret_cast<_UIntPtrType
>(__arg)
134 -
reinterpret_cast<_UIntPtrType
>(
this);
140 {
return (
reinterpret_cast<_UIntPtrType
>(this->get())
141 <
reinterpret_cast<_UIntPtrType
>(__rarg.get())); }
145 {
return (
reinterpret_cast<_UIntPtrType
>(this->get())
146 ==
reinterpret_cast<_UIntPtrType
>(__rarg.get())); }
149 #ifdef _GLIBCXX_USE_LONG_LONG
150 typedef __gnu_cxx::__conditional_type<
151 (
sizeof(
unsigned long) >=
sizeof(
void*)),
152 unsigned long,
unsigned long long>::__type _UIntPtrType;
154 typedef unsigned long _UIntPtrType;
156 _UIntPtrType _M_diff;
163 template<
typename _Tp>
167 typedef const _Tp element_type;
175 return reinterpret_cast<const _Tp*
>
176 (
reinterpret_cast<_UIntPtrType
>(
this) + _M_diff);
180 set(
const _Tp* __arg)
185 _M_diff =
reinterpret_cast<_UIntPtrType
>(__arg)
186 -
reinterpret_cast<_UIntPtrType
>(
this);
192 {
return (
reinterpret_cast<_UIntPtrType
>(this->get())
193 <
reinterpret_cast<_UIntPtrType
>(__rarg.get())); }
197 {
return (
reinterpret_cast<_UIntPtrType
>(this->get())
198 ==
reinterpret_cast<_UIntPtrType
>(__rarg.get())); }
201 #ifdef _GLIBCXX_USE_LONG_LONG
202 typedef __gnu_cxx::__conditional_type<
203 (
sizeof(
unsigned long) >=
sizeof(
void*)),
204 unsigned long,
unsigned long long>::__type _UIntPtrType;
206 typedef unsigned long _UIntPtrType;
208 _UIntPtrType _M_diff;
218 template<
typename _Tp>
219 struct _Reference_type
220 {
typedef _Tp& reference; };
223 struct _Reference_type<void>
224 {
typedef _Invalid_type& reference; };
227 struct _Reference_type<const void>
228 {
typedef const _Invalid_type& reference; };
231 struct _Reference_type<volatile void>
232 {
typedef volatile _Invalid_type& reference; };
235 struct _Reference_type<volatile const void>
236 {
typedef const volatile _Invalid_type& reference; };
243 template<
typename _Tp>
245 {
typedef _Tp type; };
247 template<
typename _Tp>
249 {
typedef _Tp type; };
283 template<
typename _Storage_policy>
287 typedef typename _Storage_policy::element_type element_type;
291 typedef typename _Unqualified_type<element_type>::type value_type;
292 typedef std::ptrdiff_t difference_type;
294 typedef typename _Reference_type<element_type>::reference reference;
302 { _Storage_policy::set(__arg); }
306 { _Storage_policy::set(__arg.get()); }
309 template<
typename _Up>
311 { _Storage_policy::set(__arg); }
315 template<
typename _Up>
317 { _Storage_policy::set(__arg.get()); }
326 _Storage_policy::set(__arg.get());
330 template<
typename _Up>
334 _Storage_policy::set(__arg.get());
338 template<
typename _Up>
340 operator=(_Up* __arg)
342 _Storage_policy::set(__arg);
349 {
return *(_Storage_policy::get()); }
354 {
return _Storage_policy::get(); }
358 operator[](std::ptrdiff_t __index)
const
359 {
return _Storage_policy::get()[__index]; }
362 #if __cplusplus >= 201103L
363 explicit operator bool()
const {
return _Storage_policy::get() != 0; }
369 operator __unspecified_bool_type()
const
371 return _Storage_policy::get() == 0 ? 0 :
372 &_Pointer_adapter::operator->;
378 {
return (_Storage_policy::get() == 0); }
382 inline friend std::ptrdiff_t
384 {
return (__lhs.get() - __rhs); }
386 inline friend std::ptrdiff_t
388 {
return (__lhs - __rhs.get()); }
390 template<
typename _Up>
391 inline friend std::ptrdiff_t
393 {
return (__lhs.get() - __rhs); }
395 template<
typename _Up>
396 inline friend std::ptrdiff_t
398 {
return (__lhs - __rhs.get()); }
400 template<
typename _Up>
401 inline std::ptrdiff_t
403 {
return (_Storage_policy::get() - __rhs.get()); }
412 #define _CXX_POINTER_ARITH_OPERATOR_SET(INT_TYPE) \
413 inline friend _Pointer_adapter \
414 operator+(const _Pointer_adapter& __lhs, INT_TYPE __offset) \
415 { return _Pointer_adapter(__lhs.get() + __offset); } \
417 inline friend _Pointer_adapter \
418 operator+(INT_TYPE __offset, const _Pointer_adapter& __rhs) \
419 { return _Pointer_adapter(__rhs.get() + __offset); } \
421 inline friend _Pointer_adapter \
422 operator-(const _Pointer_adapter& __lhs, INT_TYPE __offset) \
423 { return _Pointer_adapter(__lhs.get() - __offset); } \
425 inline _Pointer_adapter& \
426 operator+=(INT_TYPE __offset) \
428 _Storage_policy::set(_Storage_policy::get() + __offset); \
432 inline _Pointer_adapter& \
433 operator-=(INT_TYPE __offset) \
435 _Storage_policy::set(_Storage_policy::get() - __offset); \
441 _CXX_POINTER_ARITH_OPERATOR_SET(
short);
442 _CXX_POINTER_ARITH_OPERATOR_SET(
unsigned short);
443 _CXX_POINTER_ARITH_OPERATOR_SET(
int);
444 _CXX_POINTER_ARITH_OPERATOR_SET(
unsigned int);
445 _CXX_POINTER_ARITH_OPERATOR_SET(
long);
446 _CXX_POINTER_ARITH_OPERATOR_SET(
unsigned long);
447 #ifdef _GLIBCXX_USE_LONG_LONG
448 _CXX_POINTER_ARITH_OPERATOR_SET(
long long);
449 _CXX_POINTER_ARITH_OPERATOR_SET(
unsigned long long);
456 _Storage_policy::set(_Storage_policy::get() + 1);
464 _Storage_policy::set(_Storage_policy::get() + 1);
471 _Storage_policy::set(_Storage_policy::get() - 1);
479 _Storage_policy::set(_Storage_policy::get() - 1);
483 #if __cpp_lib_three_way_comparison
484 friend std::strong_ordering
487 {
return __lhs.get() <=> __rhs.get(); }
492 #define _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(OPERATOR) \
493 template<typename _Tp1, typename _Tp2> \
495 operator OPERATOR(const _Pointer_adapter<_Tp1>& __lhs, _Tp2 __rhs) \
496 { return __lhs.get() OPERATOR __rhs; } \
498 template<typename _Tp1, typename _Tp2> \
500 operator OPERATOR(_Tp1 __lhs, const _Pointer_adapter<_Tp2>& __rhs) \
501 { return __lhs OPERATOR __rhs.get(); } \
503 template<typename _Tp1, typename _Tp2> \
505 operator OPERATOR(const _Pointer_adapter<_Tp1>& __lhs, \
506 const _Pointer_adapter<_Tp2>& __rhs) \
507 { return __lhs.get() OPERATOR __rhs.get(); } \
512 _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(==)
513 _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(!=)
514 _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(<)
515 _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(<=)
516 _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(>)
517 _GCC_CXX_POINTER_COMPARISON_OPERATION_SET(>=)
520 template<typename _Tp>
523 {
return __lhs.get() ==
reinterpret_cast<void*
>(__rhs); }
525 template<
typename _Tp>
527 operator==(
int __lhs,
const _Pointer_adapter<_Tp>& __rhs)
528 {
return __rhs.get() ==
reinterpret_cast<void*
>(__lhs); }
530 template<
typename _Tp>
532 operator!=(
const _Pointer_adapter<_Tp>& __lhs,
int __rhs)
533 {
return __lhs.get() !=
reinterpret_cast<void*
>(__rhs); }
535 template<
typename _Tp>
537 operator!=(
int __lhs,
const _Pointer_adapter<_Tp>& __rhs)
538 {
return __rhs.get() !=
reinterpret_cast<void*
>(__lhs); }
544 template<
typename _Tp>
548 {
return __lhs._Tp::operator==(__rhs); }
550 template<
typename _Tp>
552 operator<=(
const _Pointer_adapter<_Tp>& __lhs,
553 const _Pointer_adapter<_Tp>& __rhs)
554 {
return __lhs._Tp::operator<(__rhs) || __lhs._Tp::operator==(__rhs); }
556 template<
typename _Tp>
558 operator!=(
const _Pointer_adapter<_Tp>& __lhs,
559 const _Pointer_adapter<_Tp>& __rhs)
560 {
return !(__lhs._Tp::operator==(__rhs)); }
562 template<
typename _Tp>
564 operator>(
const _Pointer_adapter<_Tp>& __lhs,
565 const _Pointer_adapter<_Tp>& __rhs)
566 {
return !(__lhs._Tp::operator<(__rhs) || __lhs._Tp::operator==(__rhs)); }
568 template<
typename _Tp>
570 operator>=(
const _Pointer_adapter<_Tp>& __lhs,
571 const _Pointer_adapter<_Tp>& __rhs)
572 {
return !(__lhs._Tp::operator<(__rhs)); }
574 template<
typename _CharT,
typename _Traits,
typename _StoreT>
577 const _Pointer_adapter<_StoreT>& __p)
578 {
return (__os << __p.get()); }
580 _GLIBCXX_END_NAMESPACE_VERSION
583 #if __cplusplus >= 201103L
584 namespace std _GLIBCXX_VISIBILITY(default)
586 _GLIBCXX_BEGIN_NAMESPACE_VERSION
588 template<
typename _Storage_policy>
589 struct pointer_traits<
__gnu_cxx::_Pointer_adapter<_Storage_policy>>
598 template<
typename _Up>
600 typename pointer_traits<_Storage_policy>::template rebind<_Up>>;
602 static pointer pointer_to(
typename pointer::reference __r) noexcept
606 #if __cpp_lib_concepts
607 template<
typename _Policy>
608 struct indirectly_readable_traits<
__gnu_cxx::_Pointer_adapter<_Policy>>
611 =
typename __gnu_cxx::_Pointer_adapter<_Policy>::value_type;
614 _GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * addressof(_Tp &__r) noexcept
Returns the actual address of the object or function referenced by r, even in the presence of an over...
ISO C++ entities toplevel namespace is std.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
GNU extensions for public use.
Template class basic_ostream.
__detected_or_t< __get_first_arg_t< _Ptr >, __element_type, _Ptr > element_type
The type pointed to.
typename __rebind< _Ptr, _Up >::type rebind
A pointer to a different type.
_Ptr pointer
The pointer type.
__detected_or_t< ptrdiff_t, __difference_type, _Ptr > difference_type
The type used to represent the difference between two pointers.
Random-access iterators support a superset of bidirectional iterator operations.
A storage policy for use with _Pointer_adapter<> which yields a standard pointer.
A storage policy for use with _Pointer_adapter<> which stores the pointer's address as an offset valu...