libstdc++: __gnu_cxx::pair< _T1, _T2 > Struct Template Reference

libstdc++

__gnu_cxx::pair< _T1, _T2 > Struct Template Reference

`#include <utility>`

## Public Types
typedef _T1 | first_type
typedef _T2 | second_type

## Public Member Functions
constexpr | pair (const pair &)=default
constexpr | pair (pair &&)=default
template<typename... _Args1, typename... _Args2>
constexpr | pair (piecewise_construct_t, tuple< _Args1... >, tuple< _Args2... >)
template<typename _U1, typename _U2> requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
constexpr _U2 &&constexpr | explicit (!_S_convertible< _U1 &, _U2 & >()) pair(pair< _U1
template<typename _U1, typename _U2> requires (_S_constructible<_U1&, _U2&>()) && (_S_dangles<_U1&, _U2&>())
constexpr | explicit (!_S_convertible< _U1 &, _U2 & >()) pair(pair< _U1
template<typename _U1 = _T1, typename _U2 = _T2> requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
constexpr | explicit (!_S_convertible< _U1, _U2 >()) pair(_U1 &&
template<typename _U1 = _T1, typename _U2 = _T2> requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
constexpr | explicit (!_S_convertible< _U1, _U2 >()) pair(_U1 &&__x
template<typename _U1, typename _U2> requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())
constexpr _U2 &constexpr | explicit (!_S_convertible< _U1, _U2 >()) pair(pair< _U1
template<typename _U1, typename _U2> requires (_S_constructible<_U1, _U2>()) && (_S_dangles<_U1, _U2>())
constexpr | explicit (!_S_convertible< _U1, _U2 >()) pair(pair< _U1
constexpr | explicit (!_S_convertible< const _T1 &, const _T2 & >()) pair(const type_identity_t< _T1 > &__x
template<typename _U1, typename _U2> requires (_S_constructible<const _U1&, const _U2&>()) && (!_S_dangles<_U1, _U2>())
constexpr _U2 &&constexpr | explicit (!_S_convertible< const _U1 &, const _U2 & >()) pair(const pair< _U1
template<typename _U1, typename _U2> requires (_S_constructible<const _U1&, const _U2&>()) && (_S_dangles<const _U1&, const _U2&>())
constexpr | explicit (!_S_convertible< const _U1 &, const _U2 & >()) pair(const pair< _U1
template<typename _U1, typename _U2> requires (_S_constructible<const _U1, const _U2>()) && (!_S_dangles<const _U1, const _U2>())
constexpr _U2 &constexpr | explicit (!_S_convertible< const _U1, const _U2 >()) pair(const pair< _U1
template<typename _U1, typename _U2> requires (_S_constructible<const _U1, const _U2>()) && (_S_dangles<const _U1, const _U2>())
constexpr | explicit (!_S_convertible< const _U1, const _U2 >()) pair(const pair< _U1
template<__eligible_pair_like< pair > _UPair> requires (_S_constructible_from_pair_like<_UPair>()) && (_S_dangles_from_pair_like<_UPair>())
constexpr | explicit (!_S_convertible_from_pair_like< _UPair >()) pair(_UPair &&)=delete
template<__eligible_pair_like< pair > _UPair> requires (_S_constructible_from_pair_like<_UPair>()) && (!_S_dangles_from_pair_like<_UPair>())
constexpr _U2 &&constexpr | explicit (!_S_convertible_from_pair_like< _UPair >()) pair(_UPair &&__p)
constexpr | explicit (__not_< __and_< __is_implicitly_default_constructible< _T1 >, __is_implicitly_default_constructible< _T2 > > >()) pair() noexcept(is_nothrow_default_constructible_v< _T1 > &&is_nothrow_default_constructible_v< _T2 >)
constexpr _U2 &&constexpr _U2 &__p | noexcept (_S_nothrow_constructible< _U1 &, _U2 & >())
constexpr _U2 &&__y | noexcept (_S_nothrow_constructible< _U1, _U2 >())
constexpr _U2 &constexpr _U2 &&__p | noexcept (_S_nothrow_constructible< _U1, _U2 >())
constexpr const _T2 &__y | noexcept (_S_nothrow_constructible< const _T1 &, const _T2 & >())
constexpr _U2 &&constexpr _U2 &__p | noexcept (_S_nothrow_constructible< const _U1 &, const _U2 & >())
constexpr _U2 &constexpr _U2 &&__p | noexcept (_S_nothrow_constructible< const _U1, const _U2 >())
template<__eligible_pair_like< pair > _UPair> requires (_S_assignable_from_tuple_like<_UPair>())
constexpr pair & | operator= (_UPair &&__p)
template<__eligible_pair_like< pair > _UPair> requires (_S_const_assignable_from_tuple_like<_UPair>())
constexpr const pair & | operator= (_UPair &&__p) const
pair & | operator= (const pair &)=delete
constexpr const pair & | operator= (const pair &__p) const
constexpr pair & | operator= (const pair &__p) noexcept(_S_nothrow_assignable< const _T1 &, const _T2 & >())
template<typename _U1, typename _U2> requires (_S_const_assignable<const _U1&, const _U2&>())
constexpr const pair & | operator= (const pair< _U1, _U2 > &__p) const
template<typename _U1, typename _U2> requires (_S_assignable<const _U1&, const _U2&>())
constexpr pair & | operator= (const pair< _U1, _U2 > &__p) noexcept(_S_nothrow_assignable< const _U1 &, const _U2 & >())
constexpr const pair & | operator= (pair &&__p) const
constexpr pair & | operator= (pair &&__p) noexcept(_S_nothrow_assignable< _T1, _T2 >())
template<typename _U1, typename _U2> requires (_S_const_assignable<_U1, _U2>())
constexpr const pair & | operator= (pair< _U1, _U2 > &&__p) const
template<typename _U1, typename _U2> requires (_S_assignable<_U1, _U2>())
constexpr pair & | operator= (pair< _U1, _U2 > &&__p) noexcept(_S_nothrow_assignable< _U1, _U2 >())
constexpr void | swap (const pair &__p) const noexcept(__and_v< __is_nothrow_swappable< const _T1 >, __is_nothrow_swappable< const _T2 > >)
constexpr void | swap (pair &__p) noexcept(__and_< __is_nothrow_swappable< _T1 >, __is_nothrow_swappable< _T2 > >::value)

## Public Attributes
_T1 | first
_T2 | second

## Related Symbols
(Note that these are not member symbols.)
template<typename _T1, typename _T2>
| pair (_T1, _T2) -> pair< _T1, _T2 >
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)))
template<typename _T1, typename _T2, typename _U1, typename _U2>
constexpr bool | operator== (const pair< _T1, _T2 > &__x, const pair< _U1, _U2 > &__y)
template<typename _T1, typename _T2, typename _U1, typename _U2>
constexpr common_comparison_category_t< __detail::__synth3way_t< _T1, _U1 >, __detail::__synth3way_t< _T2, _U2 > > | operator<=> (const pair< _T1, _T2 > &__x, const pair< _U1, _U2 > &__y)

## Detailed Description

template<typename _T1, typename _T2>
struct __gnu_cxx::pair< _T1, _T2 >

Struct holding two objects (or references) of arbitrary type.

Template Parameters

  _T1 | Type of the first member.
  _T2 | Type of the second member.

https://gcc.gnu.org/onlinedocs/libstdc++/manual/utilities.html

Definition at line 305 of file stl_pair.h.

## Member Typedef Documentation

## ◆ first_type

template<typename _T1, typename _T2>

typedef _T1 std::pair< _T1, _T2 >::first_type

The type of the first member.

Definition at line 308 of file stl_pair.h.

## ◆ second_type

template<typename _T1, typename _T2>

typedef _T2 std::pair< _T1, _T2 >::second_type

The type of the second member.

Definition at line 309 of file stl_pair.h.

## Constructor & Destructor Documentation

## ◆ pair() [1/2]

template<typename _T1, typename _T2>

std::pair< _T1, _T2 >::pair | ( | const pair< _T1, _T2 > & |  | ) |
| constexprdefault

Copy constructor.

## ◆ pair() [2/2]

template<typename _T1, typename _T2>

std::pair< _T1, _T2 >::pair | ( | pair< _T1, _T2 > && |  | ) |
| constexprdefault

Move constructor.

## Member Function Documentation

## ◆ explicit() [1/8]

template<typename _T1, typename _T2>
template<typename _U1, typename _U2>
requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())

_U2 &&constexpr std::pair< _T1, _T2 >::explicit | ( | !_S_convertible< _U1 &, _U2 & > | () | ) |
| constexpr

Converting constructor from a non-const pair<U1, U2> lvalue.

## ◆ explicit() [2/8]

template<typename _T1, typename _T2>
template<typename _U1 = _T1, typename _U2 = _T2>
requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())

std::pair< _T1, _T2 >::explicit | ( | !_S_convertible< _U1, _U2 > | () | ) | &&
| constexpr

Constructor accepting two values of arbitrary types.

## ◆ explicit() [3/8]

template<typename _T1, typename _T2>
template<typename _U1, typename _U2>
requires (_S_constructible<_U1, _U2>()) && (!_S_dangles<_U1, _U2>())

_U2 &constexpr std::pair< _T1, _T2 >::explicit | ( | !_S_convertible< _U1, _U2 > | () | ) |
| constexpr

Converting constructor from a non-const pair<U1, U2> rvalue.

## ◆ explicit() [4/8]

template<typename _T1, typename _T2>

std::pair< _T1, _T2 >::explicit | ( | !_S_convertible< const _T1 &, const _T2 & > | () | ) | const &
| constexpr

Constructor accepting lvalues of first_type and second_type

## ◆ explicit() [5/8]

template<typename _T1, typename _T2>
template<typename _U1, typename _U2>
requires (_S_constructible<const _U1&, const _U2&>()) && (!_S_dangles<_U1, _U2>())

_U2 &&constexpr std::pair< _T1, _T2 >::explicit | ( | !_S_convertible< const _U1 &, const _U2 & > | () | ) | const
| constexpr

Converting constructor from a const pair<U1, U2> lvalue.

## ◆ explicit() [6/8]

template<typename _T1, typename _T2>
template<typename _U1, typename _U2>
requires (_S_constructible<const _U1, const _U2>()) && (!_S_dangles<const _U1, const _U2>())

_U2 &constexpr std::pair< _T1, _T2 >::explicit | ( | !_S_convertible< const _U1, const _U2 > | () | ) | const
| constexpr

Converting constructor from a const pair<U1, U2> rvalue.

## ◆ explicit() [7/8]

template<typename _T1, typename _T2>
template<__eligible_pair_like< pair > _UPair>
requires (_S_constructible_from_pair_like<_UPair>()) && (!_S_dangles_from_pair_like<_UPair>())

_U2 &&constexpr std::pair< _T1, _T2 >::explicit | ( | !_S_convertible_from_pair_like< _UPair > | () | ) | &&
| inlineconstexpr

Definition at line 547 of file stl_pair.h.

## ◆ explicit() [8/8]

template<typename _T1, typename _T2>

std::pair< _T1, _T2 >::explicit | ( | __not_< __and_< __is_implicitly_default_constructible< _T1 >, __is_implicitly_default_constructible< _T2 > > > | () | ) |
| inlineconstexprnoexcept

Default constructor.

Definition at line 365 of file stl_pair.h.

## ◆ noexcept() [1/6]

template<typename _T1, typename _T2>

_U2 &&constexpr _U2 &__p std::pair< _T1, _T2 >::noexcept | ( | _S_nothrow_constructible< _U1 &, _U2 & > | () | ) |
| inline

Definition at line 516 of file stl_pair.h.

## ◆ noexcept() [2/6]

template<typename _T1, typename _T2>

_U2 &&__y std::pair< _T1, _T2 >::noexcept | ( | _S_nothrow_constructible< _U1, _U2 > | () | ) |
| inline

Definition at line 466 of file stl_pair.h.

## ◆ noexcept() [3/6]

template<typename _T1, typename _T2>

_U2 &constexpr _U2 &&__p std::pair< _T1, _T2 >::noexcept | ( | _S_nothrow_constructible< _U1, _U2 > | () | ) |
| inline

Definition at line 500 of file stl_pair.h.

## ◆ noexcept() [4/6]

template<typename _T1, typename _T2>

const _T2 &__y std::pair< _T1, _T2 >::noexcept | ( | _S_nothrow_constructible< const _T1 &, const _T2 & > | () | ) |
| inline

Definition at line 452 of file stl_pair.h.

## ◆ noexcept() [5/6]

template<typename _T1, typename _T2>

_U2 &&constexpr _U2 &__p std::pair< _T1, _T2 >::noexcept | ( | _S_nothrow_constructible< const _U1 &, const _U2 & > | () | ) |
| inline

Definition at line 485 of file stl_pair.h.

## ◆ noexcept() [6/6]

template<typename _T1, typename _T2>

_U2 &constexpr _U2 &&__p std::pair< _T1, _T2 >::noexcept | ( | _S_nothrow_constructible< const _U1, const _U2 > | () | ) |
| inline

Definition at line 531 of file stl_pair.h.

## ◆ operator=() [1/10]

template<typename _T1, typename _T2>
template<__eligible_pair_like< pair > _UPair>
requires (_S_assignable_from_tuple_like<_UPair>())

pair & std::pair< _T1, _T2 >::operator= | ( | _UPair && | __p | ) |
| inlineconstexpr

Definition at line 706 of file stl_pair.h.

## ◆ operator=() [2/10]

template<typename _T1, typename _T2>
template<__eligible_pair_like< pair > _UPair>
requires (_S_const_assignable_from_tuple_like<_UPair>())

const pair & std::pair< _T1, _T2 >::operator= | ( | _UPair && | __p | ) | const
| inlineconstexpr

Definition at line 716 of file stl_pair.h.

## ◆ operator=() [3/10]

template<typename _T1, typename _T2>

const pair & std::pair< _T1, _T2 >::operator= | ( | const pair< _T1, _T2 > & | __p | ) | const
| inlineconstexpr

Copy assignment operator (const)

Definition at line 661 of file stl_pair.h.

## ◆ operator=() [4/10]

template<typename _T1, typename _T2>

pair & std::pair< _T1, _T2 >::operator= | ( | const pair< _T1, _T2 > & | __p | ) |
| inlineconstexprnoexcept

Copy assignment operator.

Definition at line 614 of file stl_pair.h.

## ◆ operator=() [5/10]

template<typename _T1, typename _T2>
template<typename _U1, typename _U2>
requires (_S_const_assignable<const _U1&, const _U2&>())

const pair & std::pair< _T1, _T2 >::operator= | ( | const pair< _U1, _U2 > & | __p | ) | const
| inlineconstexpr

Converting assignment from a const pair<U1, U2> lvalue.

Definition at line 682 of file stl_pair.h.

## ◆ operator=() [6/10]

template<typename _T1, typename _T2>
template<typename _U1, typename _U2>
requires (_S_assignable<const _U1&, const _U2&>())

pair & std::pair< _T1, _T2 >::operator= | ( | const pair< _U1, _U2 > & | __p | ) |
| inlineconstexprnoexcept

Converting assignment from a const pair<U1, U2> lvalue.

Definition at line 637 of file stl_pair.h.

## ◆ operator=() [7/10]

template<typename _T1, typename _T2>

const pair & std::pair< _T1, _T2 >::operator= | ( | pair< _T1, _T2 > && | __p | ) | const
| inlineconstexpr

Move assignment operator (const)

Definition at line 671 of file stl_pair.h.

## ◆ operator=() [8/10]

template<typename _T1, typename _T2>

pair & std::pair< _T1, _T2 >::operator= | ( | pair< _T1, _T2 > && | __p | ) |
| inlineconstexprnoexcept

Move assignment operator.

Definition at line 625 of file stl_pair.h.

## ◆ operator=() [9/10]

template<typename _T1, typename _T2>
template<typename _U1, typename _U2>
requires (_S_const_assignable<_U1, _U2>())

const pair & std::pair< _T1, _T2 >::operator= | ( | pair< _U1, _U2 > && | __p | ) | const
| inlineconstexpr

Converting assignment from a non-const pair<U1, U2> rvalue.

Definition at line 693 of file stl_pair.h.

## ◆ operator=() [10/10]

template<typename _T1, typename _T2>
template<typename _U1, typename _U2>
requires (_S_assignable<_U1, _U2>())

pair & std::pair< _T1, _T2 >::operator= | ( | pair< _U1, _U2 > && | __p | ) |
| inlineconstexprnoexcept

Converting assignment from a non-const pair<U1, U2> rvalue.

Definition at line 649 of file stl_pair.h.

## ◆ swap() [1/2]

template<typename _T1, typename _T2>

void std::pair< _T1, _T2 >::swap | ( | const pair< _T1, _T2 > & | __p | ) | const
| inlineconstexprnoexcept

Definition at line 341 of file stl_pair.h.

## ◆ swap() [2/2]

template<typename _T1, typename _T2>

void std::pair< _T1, _T2 >::swap | ( | pair< _T1, _T2 > & | __p | ) |
| inlineconstexprnoexcept

Swap the first members and then the second members.

Definition at line 324 of file stl_pair.h.

## Member Data Documentation

## ◆ first

template<typename _T1, typename _T2>

_T1 std::pair< _T1, _T2 >::first

The first member.

Definition at line 311 of file stl_pair.h.

## ◆ second

template<typename _T1, typename _T2>

_T2 std::pair< _T1, _T2 >::second

The second member.

Definition at line 312 of file stl_pair.h.

The documentation for this struct was generated from the following files:

- bits/stl_iterator.h
- stl_pair.h
- tuple