31 #define _PTR_TRAITS_H 1 33 #if __cplusplus >= 201103L 37 namespace std _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
44 template<
typename _Tp>
45 struct __get_first_arg
46 {
using type = __undefined; };
48 template<
template<
typename,
typename...>
class _Template,
typename _Tp,
50 struct __get_first_arg<_Template<_Tp, _Types...>>
51 {
using type = _Tp; };
53 template<
typename _Tp>
54 using __get_first_arg_t =
typename __get_first_arg<_Tp>::type;
57 template<
typename _Tp,
typename _Up>
58 struct __replace_first_arg
61 template<
template<
typename,
typename...>
class _Template,
typename _Up,
62 typename _Tp,
typename... _Types>
63 struct __replace_first_arg<_Template<_Tp, _Types...>, _Up>
64 {
using type = _Template<_Up, _Types...>; };
66 template<
typename _Tp,
typename _Up>
67 using __replace_first_arg_t =
typename __replace_first_arg<_Tp, _Up>::type;
69 template<
typename _Tp>
71 =
typename conditional<is_void<_Tp>::value, __undefined, _Tp>::type;
77 template<
typename _Ptr>
81 template<
typename _Tp>
82 using __element_type =
typename _Tp::element_type;
84 template<
typename _Tp>
85 using __difference_type =
typename _Tp::difference_type;
87 template<
typename _Tp,
typename _Up,
typename =
void>
88 struct __rebind : __replace_first_arg<_Tp, _Up> { };
90 template<
typename _Tp,
typename _Up>
91 struct __rebind<_Tp, _Up, __void_t<typename _Tp::template
rebind<_Up>>>
92 {
using type =
typename _Tp::template
rebind<_Up>; };
100 = __detected_or_t<__get_first_arg_t<_Ptr>, __element_type, _Ptr>;
104 = __detected_or_t<ptrdiff_t, __difference_type, _Ptr>;
107 template<
typename _Up>
108 using rebind =
typename __rebind<_Ptr, _Up>::type;
111 pointer_to(__make_not_void<element_type>& __e)
112 {
return _Ptr::pointer_to(__e); }
115 "pointer type defines element_type or is like SomePointer<T, Args>");
122 template<
typename _Tp>
132 template<
typename _Up>
140 static _GLIBCXX20_CONSTEXPR
pointer 146 template<
typename _Ptr,
typename _Tp>
149 template<
typename _Tp>
151 __to_address(_Tp* __ptr) noexcept
157 #if __cplusplus <= 201703L 158 template<
typename _Ptr>
160 __to_address(
const _Ptr& __ptr)
161 {
return std::__to_address(__ptr.operator->()); }
163 template<
typename _Ptr>
165 __to_address(
const _Ptr& __ptr) noexcept
169 template<
typename _Ptr,
typename... _None>
171 __to_address(
const _Ptr& __ptr, _None...) noexcept
172 {
return std::__to_address(__ptr.operator->()); }
180 template<
typename _Tp>
182 to_address(_Tp* __ptr) noexcept
183 {
return std::__to_address(__ptr); }
192 template<
typename _Ptr>
194 to_address(
const _Ptr& __ptr) noexcept
195 {
return std::__to_address(__ptr); }
198 _GLIBCXX_END_NAMESPACE_VERSION
typename __rebind< _Ptr, _Up >::type rebind
A pointer to a different type.
_Tp * pointer
The pointer type.
ISO C++ entities toplevel namespace is std.
ptrdiff_t difference_type
Type used to represent the difference between two pointers.
__detected_or_t< __get_first_arg_t< _Ptr >, __element_type, _Ptr > element_type
The type pointed to.
__detected_or_t< ptrdiff_t, __difference_type, _Ptr > difference_type
The type used to represent the difference between two pointers.
static _GLIBCXX20_CONSTEXPR pointer pointer_to(__make_not_void< element_type > &__r) noexcept
Obtain a pointer to an object.
typename pointer_traits< _Ptr >::template rebind< _Tp > __ptr_rebind
Convenience alias for rebinding pointers.
_Tp element_type
The type pointed to.
Uniform interface to all pointer-like types.
_Ptr pointer
The pointer type.
_GLIBCXX17_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...