31 #define _PTR_TRAITS_H 1
33 #if __cplusplus >= 201103L
37 #if __cplusplus > 201703L
38 #define __cpp_lib_constexpr_memory 201811L
39 namespace __gnu_debug {
struct _Safe_iterator_base; }
42 namespace std _GLIBCXX_VISIBILITY(default)
44 _GLIBCXX_BEGIN_NAMESPACE_VERSION
49 template<
typename _Tp>
50 struct __get_first_arg
51 {
using type = __undefined; };
53 template<
template<
typename,
typename...>
class _Template,
typename _Tp,
55 struct __get_first_arg<_Template<_Tp, _Types...>>
56 {
using type = _Tp; };
58 template<
typename _Tp>
59 using __get_first_arg_t =
typename __get_first_arg<_Tp>::type;
62 template<
typename _Tp,
typename _Up>
63 struct __replace_first_arg
66 template<
template<
typename,
typename...>
class _Template,
typename _Up,
67 typename _Tp,
typename... _Types>
68 struct __replace_first_arg<_Template<_Tp, _Types...>, _Up>
69 {
using type = _Template<_Up, _Types...>; };
71 template<
typename _Tp,
typename _Up>
72 using __replace_first_arg_t =
typename __replace_first_arg<_Tp, _Up>::type;
74 template<
typename _Tp>
76 =
typename conditional<is_void<_Tp>::value, __undefined, _Tp>::type;
82 template<
typename _Ptr>
86 template<
typename _Tp>
87 using __element_type =
typename _Tp::element_type;
89 template<
typename _Tp>
90 using __difference_type =
typename _Tp::difference_type;
92 template<
typename _Tp,
typename _Up,
typename =
void>
93 struct __rebind : __replace_first_arg<_Tp, _Up> { };
95 template<
typename _Tp,
typename _Up>
96 struct __rebind<_Tp, _Up, __void_t<typename _Tp::template
rebind<_Up>>>
97 {
using type =
typename _Tp::template
rebind<_Up>; };
105 = __detected_or_t<__get_first_arg_t<_Ptr>, __element_type, _Ptr>;
109 = __detected_or_t<ptrdiff_t, __difference_type, _Ptr>;
112 template<
typename _Up>
113 using rebind =
typename __rebind<_Ptr, _Up>::type;
116 pointer_to(__make_not_void<element_type>& __e)
117 {
return _Ptr::pointer_to(__e); }
120 "pointer type defines element_type or is like SomePointer<T, Args>");
127 template<
typename _Tp>
137 template<
typename _Up>
145 static _GLIBCXX20_CONSTEXPR
pointer
151 template<
typename _Ptr,
typename _Tp>
154 template<
typename _Tp>
156 __to_address(_Tp* __ptr) noexcept
162 #if __cplusplus <= 201703L
163 template<
typename _Ptr>
165 __to_address(
const _Ptr& __ptr)
166 {
return std::__to_address(__ptr.operator->()); }
168 template<
typename _Ptr>
170 __to_address(
const _Ptr& __ptr) noexcept
174 template<
typename _Ptr,
typename... _None>
176 __to_address(
const _Ptr& __ptr, _None...) noexcept
178 if constexpr (is_base_of_v<__gnu_debug::_Safe_iterator_base, _Ptr>)
179 return std::__to_address(__ptr.base().operator->());
181 return std::__to_address(__ptr.operator->());
184 #define __cpp_lib_to_address 201711L
192 template<
typename _Tp>
194 to_address(_Tp* __ptr) noexcept
195 {
return std::__to_address(__ptr); }
204 template<
typename _Ptr>
206 to_address(
const _Ptr& __ptr) noexcept
207 {
return std::__to_address(__ptr); }
210 _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.
typename pointer_traits< _Ptr >::template rebind< _Tp > __ptr_rebind
Convenience alias for rebinding pointers.
GNU debug classes for public use.
Uniform interface to all pointer-like types.
__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.
_Tp * pointer
The pointer type.
ptrdiff_t difference_type
Type used to represent the difference between two pointers.
_Tp element_type
The type pointed to.
static constexpr pointer pointer_to(__make_not_void< element_type > &__r) noexcept
Obtain a pointer to an object.