STD::PAIR(3cxx)
π std::pair< _T1, _T2 >(3cxx) β NAME π
okay so bestie, welcome to the 3cxx manual page for std::pair< _T1, _T2 > β literally the struct holding two objects of arbitrary type. That's the whole serve: two little slots, any types you want, main character energy for your tuples-but-smaller era. β¨
πΈ SYNOPSIS πΈ
#include <utility>
It inherits __pair_base< _T1, _T2 >. π«Ά
π¦ Public Types π¦
typedef _T1 first_typeβ the type of the first member.typedef _T2 second_typeβ the type of the second member.
π Public Member Functions π
- Default constructor β the
constexpr pair ()situation. Full signature, copied exactly because we do not play with template text:
template<typename _U1 = _T1, typename _U2 = _T2, typename enable_if<
__and_< __is_implicitly_default_constructible< _U1 >,
__is_implicitly_default_constructible< _U2 > > ::value, bool >::type
= true> constexpr pair ()
- Zero-as-null-pointer-constant constructor, first variant β takes
__zero_as_null_pointer_constantplus_U2 &&__y,...:
template<typename _U2 , __enable_if_t< __and_< is_pointer< _T1 >,
__not_< is_reference< _U2 > >, is_constructible< _T2, _U2 >, __not_<
is_constructible< _T2, const _U2 & > >, is_convertible< _U2, _T2 >
>::value, bool > = true> constexpr pair
(__zero_as_null_pointer_constant, _U2 &&__y,...)
- Zero-as-null-pointer-constant constructor, second variant β same shape,
bool > = false, and the convertibility check is negated:
template<typename _U2 , __enable_if_t< __and_< is_pointer< _T1 >,
__not_< is_reference< _U2 > >, is_constructible< _T2, _U2 >, __not_<
is_constructible< _T2, const _U2 & > >, __not_< is_convertible< _U2,
_T2 > > >::value, bool > = false> constexpr pair
(__zero_as_null_pointer_constant, _U2 &&__y,...)
- Zero-as-null-pointer-constant constructor, third variant β now the first parameter is the one taking
__zero_as_null_pointer_constant:
template<typename _U1 , __enable_if_t< __and_< __not_< is_reference< _U1
> >, is_pointer< _T2 >, is_constructible< _T1, _U1 >, __not_<
is_constructible< _T1, const _U1 & > >, is_convertible< _U1, _T1 >
>::value, bool > = true> constexpr pair (_U1 &&__x,
__zero_as_null_pointer_constant,...)
- Zero-as-null-pointer-constant constructor, fourth variant β same but
bool > = falseand the convertibility check is negated:
template<typename _U1 , __enable_if_t< __and_< __not_< is_reference< _U1
> >, is_pointer< _T2 >, is_constructible< _T1, _U1 >, __not_<
is_constructible< _T1, const _U1 & > >, __not_< is_convertible< _U1,
_T1 > > >::value, bool > = false> constexpr pair (_U1 &&__x,
__zero_as_null_pointer_constant,...)
- Move-constructible pair constructor, implicit version β
_PCCPsays_MoveConstructiblePairand_ImplicitlyMoveConvertiblePairare both true:
template<typename _U1 , typename _U2 , typename enable_if<
_PCCP::template _MoveConstructiblePair< _U1, _U2 >()
&&_PCCP::template _ImplicitlyMoveConvertiblePair< _U1, _U2 >(), bool
>::type = true> constexpr pair (_U1 &&__x, _U2 &&__y)
- Move-constructible pair constructor, non-implicit version β
_PCCPsays_MoveConstructiblePairis true and_ImplicitlyMoveConvertiblePairis not:
template<typename _U1 , typename _U2 , typename enable_if<
_PCCP::template _MoveConstructiblePair< _U1, _U2 >()
&&!_PCCP::template _ImplicitlyMoveConvertiblePair< _U1, _U2 >(),
bool >::type = false> constexpr pair (_U1 &&__x, _U2 &&__y)
- Construct from two const lvalues, allowing implicit conversions β the description says exactly that: construct from two const lvalues, allowing implicit conversions.
template<typename _U1 = _T1, typename _U2 = _T2, typename enable_if<
_PCCP::template _ConstructiblePair< _U1, _U2 >() &&_PCCP::template
_ImplicitlyConvertiblePair< _U1, _U2 >(), bool >::type = true>
constexpr pair (const _T1 &__a, const _T2 &__b)
- Construct from two const lvalues, disallowing implicit conversions β same base description, but the implicit-conversion bit is turned off:
template<typename _U1 = _T1, typename _U2 = _T2, typename enable_if<
_PCCP::template _ConstructiblePair< _U1, _U2 >() &&!_PCCP::template
_ImplicitlyConvertiblePair< _U1, _U2 >(), bool >::type = false>
constexpr pair (const _T1 &__a, const _T2 &__b)
- Copy constructor β literally the copy constructor:
constexpr pair (const pair &)=default
- Converting copy constructor, implicit version β
_PCCFPpair-constructible and implicitly convertible:
template<typename _U1 , typename _U2 , typename enable_if< _PCCFP< _U1,
_U2 >::template _ConstructiblePair< _U1, _U2 >() &&_PCCFP< _U1, _U2
>::template _ImplicitlyConvertiblePair< _U1, _U2 >(), bool >::type
= true> constexpr pair (const pair< _U1, _U2 > &__p)
- Converting copy constructor, non-implicit version β
_PCCFPpair-constructible and not implicitly convertible:
template<typename _U1 , typename _U2 , typename enable_if< _PCCFP< _U1,
_U2 >::template _ConstructiblePair< _U1, _U2 >() &&!_PCCFP< _U1, _U2
>::template _ImplicitlyConvertiblePair< _U1, _U2 >(), bool >::type
= false> constexpr pair (const pair< _U1, _U2 > &__p)
- Move constructor β literally the move constructor:
constexpr pair (pair &&)=default
- Converting move constructor, implicit version β
_PCCFPmove-constructible and implicitly move-convertible:
template<typename _U1 , typename _U2 , typename enable_if< _PCCFP< _U1,
_U2 >::template _MoveConstructiblePair< _U1, _U2 >() &&_PCCFP< _U1,
_U2 >::template _ImplicitlyMoveConvertiblePair< _U1, _U2 >(), bool
>::type = true> constexpr pair (pair< _U1, _U2 > &&__p)
- Converting move constructor, non-implicit version β
_PCCFPmove-constructible and not implicitly move-convertible:
template<typename _U1 , typename _U2 , typename enable_if< _PCCFP< _U1,
_U2 >::template _MoveConstructiblePair< _U1, _U2 >() &&!_PCCFP< _U1,
_U2 >::template _ImplicitlyMoveConvertiblePair< _U1, _U2 >(), bool
>::type = false> constexpr pair (pair< _U1, _U2 > &&__p)
- Piecewise constructor β takes
piecewise_construct_tand two tuples:
template<typename... _Args1, typename... _Args2> constexpr pair
(piecewise_construct_t, tuple< _Args1... >, tuple< _Args2... >)
- Copy assignment operator β the
__conditional_tsituation:
pair & operator= (__conditional_t< __and_< is_copy_assignable< _T1 >,
is_copy_assignable< _T2 > >::value, const pair &, const __nonesuch &
> __p)
- Move assignment operator β also has a
noexceptclause:
pair & operator= (__conditional_t< __and_< is_move_assignable< _T1 >,
is_move_assignable< _T2 > >::value, pair &&, __nonesuch && > __p)
noexcept(__and_< is_nothrow_move_assignable< _T1 >,
is_nothrow_move_assignable< _T2 > >::value)
- Converting copy assignment operator β
enable_ifon assignability withconst_U1andconst_U2exactly as printed:
template<typename _U1 , typename _U2 > enable_if< __and_< is_assignable<
_T1 &, const_U1 & >, is_assignable< _T2 &, const_U2 & > >::value,
pair & >::type operator= (const pair< _U1, _U2 > &__p)
- Converting move assignment operator β
enable_ifon assignability with_U1 &&and_U2 &&:
template<typename _U1 , typename _U2 > enable_if< __and_< is_assignable<
_T1 &, _U1 && >, is_assignable< _T2 &, _U2 && > >::value, pair &
>::type operator= (pair< _U1, _U2 > &&__p)
swapβ swaps the first members and then the second members. That's the whole bit:
constexpr void swap (pair &__p) noexcept(__and_< __is_nothrow_swappable<
_T1 >, __is_nothrow_swappable< _T2 > >::value)
π Public Attributes π
_T1 firstβ the first member._T2 secondβ the second member.
π₯ Related Symbols π₯
Note that these are not member symbols. They're related, bestie, not members. Keep the distinction cute and clear.
make_pairβ a convenience wrapper for creating a pair from two objects:
template<typename _T1 , typename _T2 > constexpr pair< typename
__decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2
>::__type > make_pair (_T1 &&__x, _T2 &&__y)
- Deduction guide for
pairβ description in the page says: two pairs of the same type are equal iff their members are equal:
template<typename _T1 , typename _T2 > pair (_T1, _T2) -> pair< _T1,
_T2 >
operator==β two pairs of the same type are equal iff their members are equal:
template<typename _T1 , typename _T2 > constexpr bool operator==
(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
operator<β here's the signature:
template<typename _T1 , typename _T2 > constexpr bool operator<
(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
operator!=β usesoperator==to find the result:
template<typename _T1 , typename _T2 > constexpr bool operator!=
(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
operator>β usesoperator<to find the result:
template<typename _T1 , typename _T2 > constexpr bool operator>
(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
operator<=β usesoperator<to find the result:
template<typename _T1 , typename _T2 > constexpr bool operator<=
(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
operator>=β usesoperator<to find the result:
template<typename _T1 , typename _T2 > constexpr bool operator>=
(const pair< _T1, _T2 > &__x, const pair< _T1, _T2 > &__y)
- Free
swapβenable_ifon__is_swappable< _T1 >and__is_swappable< _T2 >, with anoexceptthat checks__x.swap(__y):
template<typename _T1 , typename _T2 > constexpr enable_if< __and_<
__is_swappable< _T1 >, __is_swappable< _T2 > >::value >::type
swap (pair< _T1, _T2 > &__x, pair< _T1, _T2 > &__y)
noexcept(noexcept(__x.swap(__y)))
π Detailed Description π
The declaration in the manpage is printed like this β stray quote and all, so I'm keeping it exactly:
template<typename _T1, typename _T2>
struct std::pair< _T1, _T2 >"Struct holding two objects of arbitrary
type.
Template Parameters
_T1β type of first object._T2β type of second object.
The reference link, copied exactly:
https://gcc.gnu.org/onlinedocs/libstdc++/manual/utilities.html
β¨ AUTHOR β¨
okay so nobody actually sat down and hand-wrote this one, bestie π it was Generated automatically by Doxygen for libstdc++ from the source code. so like, the robot did the typing, and the source code did the ~vibes~ π no cap, the code is the real main character here and Doxygen is just the icon doing the transcription π
and that's a wrap on std::pair< _T1, _T2 >, section 3cxx of the libstdc++ manual π¦ the whole thing lives under the libstdc++ banner, and it got stamped with its little date-and-version footer at the bottom of the page β you know the one, the tiny line that goes libstdc++ β¦ std::pair< _T1, _T2 >(3cxx). absolute serve, no notes β¨
go forth and pair your _T1 with your _T2, bestie π you ate π«Ά π
π¦ where this page comes from
- ubuntu noble: libstdc++-14-doc 14-20240412-0ubuntu1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms