1 #ifndef INCG_PHI_CORE_POINTER_TRAITS_HPP 2 #define INCG_PHI_CORE_POINTER_TRAITS_HPP 4 #include "phi/phi_config.hpp" 6 #if PHI_HAS_EXTENSION_PRAGMA_ONCE() 10 #include "phi/compiler_support/constexpr.hpp" 11 #include "phi/compiler_support/noexcept.hpp" 12 #include "phi/compiler_support/warning.hpp" 13 #include "phi/core/address_of.hpp" 14 #include "phi/core/ptrdiff_t.hpp" 15 #include "phi/type_traits/conditional.hpp" 16 #include "phi/type_traits/detail/nat.hpp" 17 #include "phi/type_traits/has_difference_type.hpp" 18 #include "phi/type_traits/has_element_type.hpp" 19 #include "phi/type_traits/integral_constant.hpp" 20 #include "phi/type_traits/is_void.hpp" 22 DETAIL_PHI_BEGIN_NAMESPACE()
26 template <typename PointerT, bool = has_element_type<PointerT>::value>
29 template <
typename Po
interT>
32 using type =
typename PointerT::element_type;
35 template <
template <
typename,
typename...>
typename FancyPointerT,
typename TypeT,
39 using type =
typename FancyPointerT<TypeT, ArgsT...>::element_type;
42 template <
template <
typename,
typename...>
typename FancyPointerT,
typename TypeT,
49 template <typename PointerT, bool = has_difference_type<PointerT>::value>
52 using type = ptrdiff_t;
55 template <
typename Po
interT>
58 using type =
typename PointerT::difference_type;
61 template <
typename TypeT,
typename OtherT>
65 template <
typename Type2T>
68 template <
typename Type2T>
69 static true_type test(
typename Type2T::template rebind<OtherT>* = 0);
72 PHI_CLANG_SUPPRESS_WARNING_WITH_PUSH(
"-Wzero-as-null-pointer-constant")
74 static PHI_CONSTEXPR_AND_CONST
bool value = decltype(test<TypeT>(0))::value;
76 PHI_CLANG_SUPPRESS_WARNING_POP()
79 template <typename TypeT, typename OtherT, bool = has_rebind<TypeT, OtherT>::value>
82 #if PHI_CPP_STANDARD_IS_ATLEAST(11) 83 using type =
typename TypeT::template rebind<OtherT>;
85 using type =
typename TypeT::template rebind<OtherT>::other;
89 template <
template <
typename,
typename...>
typename FancyPointerT,
typename TypeT,
90 typename... ArgsT,
typename OtherT>
93 #if PHI_CPP_STANDARD_IS_ATLEAST(11) 94 using type =
typename FancyPointerT<TypeT, ArgsT...>::template rebind<OtherT>;
96 using type =
typename FancyPointerT<TypeT, ArgsT...>::template rebind<OtherT>::other;
100 template <
template <
typename,
typename...>
typename FancyPointerT,
typename TypeT,
101 typename... ArgsT,
typename OtherT>
104 using type = FancyPointerT<OtherT, ArgsT...>;
108 template <
typename Po
interT>
112 using pointer = PointerT;
113 using difference_type =
typename detail::pointer_traits_difference_type<pointer>::type;
116 #if PHI_CPP_STANDARD_IS_ATLEAST(11) 117 template <
typename OtherT>
118 using rebind =
typename detail::pointer_traits_rebind<pointer, OtherT>::type;
120 template <
typename OtherT>
123 using other =
typename detail::pointer_traits_rebind<pointer, OtherT>::type;
128 static PHI_CONSTEXPR pointer
131 return pointer::pointer_to(ptr);
135 template <
typename TypeT>
139 using pointer = TypeT*;
140 using difference_type = ptrdiff_t;
141 using element_type = TypeT;
143 #if PHI_CPP_STANDARD_IS_ATLEAST(11) 144 template <
typename OtherT>
145 using rebind = OtherT*;
147 template <
typename OtherT>
150 using other = OtherT*;
155 static PHI_CONSTEXPR pointer
158 return address_of(ptr);
162 #if PHI_CPP_STANDARD_IS_ATLEAST(11) 164 template <
typename FromT,
typename ToT>
169 template <
typename FromT,
typename ToT>
174 DETAIL_PHI_END_NAMESPACE()
176 #endif // INCG_PHI_CORE_POINTER_TRAITS_HPP Definition: integral_constant.hpp:19
Definition: pointer_traits.hpp:27
Definition: pointer_traits.hpp:80
Definition: test_macros.hpp:18
Definition: pointer_traits.hpp:121
Definition: pointer_traits.hpp:136
Definition: pointer_traits.hpp:109
Definition: pointer_traits.hpp:62
Definition: is_void.hpp:17
Definition: pointer_traits.hpp:50