1 #ifndef INCG_PHI_CORE_CONTAINER_ARRAY_HPP 2 #define INCG_PHI_CORE_CONTAINER_ARRAY_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/nodiscard.hpp" 12 #include "phi/compiler_support/noexcept.hpp" 13 #include "phi/core/boolean.hpp" 14 #include "phi/core/forward.hpp" 15 #include "phi/type_traits/conditional.hpp" 16 #include "phi/type_traits/detail/nat.hpp" 17 #include "phi/type_traits/enable_if.hpp" 18 #include "phi/type_traits/is_constructible.hpp" 19 #include "phi/type_traits/is_convertible.hpp" 20 #include "phi/type_traits/is_copy_assignable.hpp" 21 #include "phi/type_traits/is_default_constructible.hpp" 22 #include "phi/type_traits/is_implicitly_default_constructible.hpp" 23 #include "phi/type_traits/is_move_assignable.hpp" 24 #include "phi/type_traits/is_nothrow_copy_assignable.hpp" 25 #include "phi/type_traits/is_nothrow_copy_constructible.hpp" 26 #include "phi/type_traits/is_nothrow_default_constructible.hpp" 27 #include "phi/type_traits/is_nothrow_move_assignable.hpp" 28 #include "phi/type_traits/is_nothrow_swappable.hpp" 29 #include "phi/type_traits/is_swappable.hpp" 31 DETAIL_PHI_BEGIN_NAMESPACE()
34 template <typename FirstT, typename SecondT>
37 static PHI_CONSTEXPR_AND_CONST
bool enable_implicit_default_constructor =
41 static PHI_CONSTEXPR_AND_CONST
bool enable_explicit_default_constructor =
43 !enable_implicit_default_constructor;
45 static PHI_CONSTEXPR_AND_CONST
bool enable_nothrow_default_constructor =
49 static PHI_CONSTEXPR_AND_CONST
bool enable_nothrow_copy_constructor =
53 template <
typename OtherFirstT,
typename OtherSecondT>
54 static PHI_CONSTEXPR_AND_CONST
bool enable_explicit_constructor =
60 template <
typename OtherFirstT,
typename OtherSecondT>
61 static PHI_CONSTEXPR_AND_CONST
bool enable_implicit_constructor =
69 using first_type = FirstT;
70 using second_type = SecondT;
73 template <typename enable_if<enable_explicit_default_constructor>::type* =
nullptr>
74 PHI_CONSTEXPR
explicit pair() PHI_NOEXCEPT_EXPR(enable_nothrow_default_constructor)
80 template <typename enable_if<enable_implicit_default_constructor>::type* =
nullptr>
81 PHI_CONSTEXPR pair() PHI_NOEXCEPT_EXPR(enable_nothrow_default_constructor)
90 pair(pair
const&) =
default;
93 pair(pair&&) =
default;
97 enable_explicit_constructor<const FirstT&, const SecondT&>>::type* =
nullptr>
98 PHI_CONSTEXPR
explicit pair(
const FirstT& first_arg,
const SecondT& second_arg)
99 PHI_NOEXCEPT_EXPR(enable_nothrow_copy_constructor)
106 enable_implicit_constructor<const FirstT&, const SecondT&>>::type* =
nullptr>
107 PHI_CONSTEXPR pair(
const FirstT& first_arg,
const SecondT& second_arg)
108 PHI_NOEXCEPT_EXPR(enable_nothrow_copy_constructor)
115 template <
typename OtherFirstT = FirstT,
typename OtherSecondT = SecondT,
118 PHI_CONSTEXPR
explicit pair(OtherFirstT&& other_first, OtherSecondT&& other_second)
121 : first{forward<OtherFirstT>(other_first)}
122 , second{forward<OtherSecondT>(other_second)}
127 template <
typename OtherFirstT = FirstT,
typename OtherSecondT = SecondT,
130 PHI_CONSTEXPR pair(OtherFirstT&& other_first, OtherSecondT&& other_second)
133 : first{forward<OtherFirstT>(other_first)}
134 , second{forward<OtherSecondT>(other_second)}
138 template <
typename OtherFirstT,
typename OtherSecondT,
139 typename enable_if<enable_explicit_constructor<
const OtherFirstT&,
140 const OtherSecondT&>>::type* =
nullptr>
144 : first{other_pair.first}
145 , second(other_pair.second)
149 template <
typename OtherFirstT,
typename OtherSecondT,
150 typename enable_if<enable_implicit_constructor<
const OtherFirstT&,
151 const OtherSecondT&>>::type* =
nullptr>
155 : first{other_pair.first}
156 , second{other_pair.second}
160 template <
typename OtherFirstT,
typename OtherSecondT,
166 : first{forward<OtherFirstT>(other_pair.first)}
167 , second{forward<OtherSecondT>(other_pair.second)}
171 template <
typename OtherFirstT,
typename OtherSecondT,
177 : first{forward<OtherFirstT>(other_pair.first)}
178 , second{forward<OtherSecondT>(other_pair.second)}
181 pair& operator=(
const pair&) =
default;
183 pair& operator=(pair&&) =
default;
187 pair,
nat>::type
const& other_pair)
191 first = other_pair.first;
192 second = other_pair.second;
197 PHI_CONSTEXPR pair& operator=(
200 pair,
nat>::type&& other_pair)
204 first = forward<first_type>(other_pair.first);
205 second = forward<second_type>(other_pair.second);
210 PHI_CONSTEXPR
void swap(pair& other_pair) PHI_NOEXCEPT_EXPR(
215 swap(first, other_pair.first);
216 swap(second, other_pair.second);
219 PHI_CONSTEXPR
void flip() PHI_NOEXCEPT_EXPR(
228 PHI_NOEXCEPT_EXPR(enable_nothrow_copy_constructor)
239 template <
typename FirstT,
typename SecondT>
242 return lhs.first == rhs.first && lhs.second == rhs.second;
245 template <
typename FirstT,
typename SecondT>
248 return !(lhs == rhs);
251 template <
typename FirstT,
typename SecondT>
254 return lhs.first < rhs.first || (!(rhs.first < lhs.first) && lhs.second < rhs.second);
257 template <
typename FirstT,
typename SecondT>
263 template <
typename FirstT,
typename SecondT>
269 template <
typename FirstT,
typename SecondT>
275 template <
typename FirstT,
typename SecondT>
284 template <
typename FirstT,
typename SecondT>
294 template <
typename FirstT,
typename SecondT>
300 #if PHI_HAS_FEATURE_DEDUCTION_GUIDES() 301 template <
typename FirstTypeT,
typename SecondTypeT>
305 DETAIL_PHI_END_NAMESPACE()
307 #endif // INCG_PHI_CORE_CONTAINER_ARRAY_HPP Definition: is_nothrow_copy_constructible.hpp:26
Definition: is_nothrow_swappable.hpp:21
Definition: is_nothrow_move_assignable.hpp:20
Definition: conditional.hpp:13
Definition: is_default_constructible.hpp:91
Definition: is_copy_assignable.hpp:20
Definition: is_implicitly_default_constructible.hpp:34
Definition: is_convertible.hpp:217
Definition: is_nothrow_copy_assignable.hpp:20
Definition: enable_if.hpp:15
Definition: is_constructible.hpp:73
Definition: is_nothrow_default_constructible.hpp:21
Definition: is_nothrow_constructible.hpp:160
Definition: is_move_assignable.hpp:20
Definition: is_swappable.hpp:21
Definition: is_convertible.hpp:227