Generic container for two elements.
hana::pair
is conceptually the same as std::pair
. However, hana::pair
automatically compresses the storage of empty types, and as a result it does not have the .first
and .second
members. Instead, one must use the hana::first
and hana::second
free functions to access the elements of a pair.
Comparable
(x, y)
and ‘(x’, y')are equal if and only if both
x == x'and
y == y'`. Orderable
Foldable
Product
Product
is the simplest one possible; the first element of a pair (x, y)
is x
, and its second element is y
. Synopsis of associated functions | |
template<> | |
constexpr auto | make< pair_tag > |
Creates a hana::pair with the given elements. More... | |
constexpr auto | make_pair = make<pair_tag> |
Alias to make<pair_tag> ; provided for convenience. More... | |
Friends | |
template<typename X , typename Y > | |
constexpr auto | operator== (X &&x, Y &&y) |
Equivalent to hana::equal | |
template<typename X , typename Y > | |
constexpr auto | operator!= (X &&x, Y &&y) |
Equivalent to hana::not_equal | |
template<typename X , typename Y > | |
constexpr auto | operator< (X &&x, Y &&y) |
Equivalent to hana::less | |
template<typename X , typename Y > | |
constexpr auto | operator> (X &&x, Y &&y) |
Equivalent to hana::greater | |
template<typename X , typename Y > | |
constexpr auto | operator<= (X &&x, Y &&y) |
Equivalent to hana::less_equal | |
template<typename X , typename Y > | |
constexpr auto | operator>= (X &&x, Y &&y) |
Equivalent to hana::greater_equal | |
Public Member Functions | |
constexpr | pair () |
Default constructs the pair . Only exists when both elements of the pair are default constructible. | |
constexpr | pair (First const &first, Second const &second) |
Initialize each element of the pair with the corresponding element. Only exists when both elements of the pair are copy-constructible. | |
template<typename T , typename U > | |
constexpr | pair (T &&t, U &&u) |
Initialize both elements of the pair by perfect-forwarding the corresponding argument. Only exists when both arguments are implicitly-convertible to the corresponding element of the pair. | |
template<typename T , typename U > | |
constexpr | pair (pair< T, U > const &other) |
Copy-initialize a pair from another pair. Only exists when both elements of the source pair are implicitly convertible to the corresponding element of the constructed pair. | |
template<typename T , typename U > | |
constexpr | pair (pair< T, U > &&other) |
Move-initialize a pair from another pair. Only exists when both elements of the source pair are implicitly convertible to the corresponding element of the constructed pair. | |
template<typename T , typename U > | |
constexpr pair & | operator= (pair< T, U > const &other) |
Assign a pair to another pair. Only exists when both elements of the destination pair are assignable from the corresponding element in the source pair. | |
template<typename T , typename U > | |
constexpr pair & | operator= (pair< T, U > &&other) |
Move-assign a pair to another pair. Only exists when both elements of the destination pair are move-assignable from the corresponding element in the source pair. | |
Creates a hana::pair
with the given elements.
Alias to make<pair_tag>
; provided for convenience.