31#define _PTR_TRAITS_H 1
33#if __cplusplus >= 201103L
37#if __cplusplus > 201703L
38#define __cpp_lib_constexpr_memory 201811L
39namespace __gnu_debug {
struct _Safe_iterator_base; }
42namespace std _GLIBCXX_VISIBILITY(default)
44_GLIBCXX_BEGIN_NAMESPACE_VERSION
49 template<
typename _Tp,
typename _Up>
50 struct __replace_first_arg
53 template<
template<
typename,
typename...>
class _Template,
typename _Up,
54 typename _Tp,
typename... _Types>
55 struct __replace_first_arg<_Template<_Tp, _Types...>, _Up>
56 {
using type = _Template<_Up, _Types...>; };
58 template<
typename _Tp,
typename _Up>
59 using __replace_first_arg_t =
typename __replace_first_arg<_Tp, _Up>::type;
61 template<
typename _Tp>
63 =
typename conditional<is_void<_Tp>::value, __undefined, _Tp>::type;
65 template<
typename _Ptr>
66 struct __ptr_traits_elem_1
69 template<
template<
typename,
typename...>
class _SomePointer,
typename _Tp,
71 struct __ptr_traits_elem_1<_SomePointer<_Tp, _Args...>>
73 using element_type = _Tp;
74 using pointer = _SomePointer<_Tp, _Args...>;
77 pointer_to(__make_not_void<element_type>& __e)
78 {
return pointer::pointer_to(__e); }
81 template<
typename _Ptr,
typename =
void>
82 struct __ptr_traits_elem : __ptr_traits_elem_1<_Ptr>
85 template<
typename _Ptr>
86 struct __ptr_traits_elem<_Ptr, __void_t<typename _Ptr::element_type>>
88 using element_type =
typename _Ptr::element_type;
91 pointer_to(__make_not_void<element_type>& __e)
92 {
return _Ptr::pointer_to(__e); }
99 template<
typename _Ptr>
103 template<
typename _Tp>
104 using __difference_type =
typename _Tp::difference_type;
106 template<
typename _Tp,
typename _Up,
typename =
void>
107 struct __rebind : __replace_first_arg<_Tp, _Up> { };
109 template<
typename _Tp,
typename _Up>
110 struct __rebind<_Tp, _Up, __void_t<typename _Tp::template
rebind<_Up>>>
111 {
using type =
typename _Tp::template
rebind<_Up>; };
119 = __detected_or_t<ptrdiff_t, __difference_type, _Ptr>;
122 template<
typename _Up>
123 using rebind =
typename __rebind<_Ptr, _Up>::type;
130 template<
typename _Tp>
140 template<
typename _Up>
148 static _GLIBCXX20_CONSTEXPR
pointer
154 template<
typename _Ptr,
typename _Tp>
157 template<
typename _Tp>
159 __to_address(_Tp* __ptr)
noexcept
165#if __cplusplus <= 201703L
166 template<
typename _Ptr>
168 __to_address(
const _Ptr& __ptr)
169 {
return std::__to_address(__ptr.operator->()); }
172 template<
typename _Ptr>
174 __to_address(
const _Ptr& __ptr)
noexcept
178 template<
typename _Ptr,
typename... _None>
180 __to_address(
const _Ptr& __ptr, _None...) noexcept
182 if constexpr (is_base_of_v<__gnu_debug::_Safe_iterator_base, _Ptr>)
183 return std::__to_address(__ptr.base().operator->());
185 return std::__to_address(__ptr.operator->());
188#define __cpp_lib_to_address 201711L
196 template<
typename _Tp>
198 to_address(_Tp* __ptr)
noexcept
199 {
return std::__to_address(__ptr); }
208 template<
typename _Ptr>
210 to_address(
const _Ptr& __ptr)
noexcept
211 {
return std::__to_address(__ptr); }
214_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.
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.