template<typename Type1, typename Type2>
bn::pair class

Provides a way to store two heterogeneous objects as a single unit.

Template parameters
Type1 First element type.
Type2 Second element type.

Public types

using first_type = Type1
First element type alias.
using second_type = Type2
Second element type alias.

Constructors, destructors, conversion operators

pair() defaulted constexpr
Default constructor.
pair(const first_type& x, const second_type& y) constexpr
Initializes first with x and second with y.
template<typename OtherType1, typename OtherType2>
pair(OtherType1&& x, OtherType2&& y) constexpr
Initializes first with forward<OtherType1>(x) and second with forward<OtherType2>(y).
pair(const pair& other) defaulted constexpr
Default copy constructor.
template<typename OtherType1, typename OtherType2>
pair(const pair<OtherType1, OtherType2>& other) constexpr
Initializes first with other.first and second with other.second.
pair(pair&& other) defaulted constexpr
Default move constructor.
template<typename OtherType1, typename OtherType2>
pair(pair<OtherType1, OtherType2>&& other) constexpr
Initializes first with move(other.first) and second with move(other.second).

Public functions

auto operator=(const pair& other) -> pair& defaulted constexpr
Default copy assignment operator.
template<typename OtherType1, typename OtherType2>
auto operator=(const pair<OtherType1, OtherType2>& other) -> pair& constexpr
Assigns other.first to first and other.second to second.
auto operator=(pair&& other) -> pair& defaulted constexpr
Default move assignment operator.
template<typename OtherType1, typename OtherType2>
auto operator=(pair<OtherType1, OtherType2>&& other) -> pair& constexpr
Assigns move(other.first) to first and move(other.second) to second.
void swap(pair& other) constexpr
Exchanges the contents of this pair with those of the other one.

Public variables

first_type first
First element.
second_type second
Second element.

Friends

auto swap(pair& a, pair& b) -> friend void constexpr
Exchanges the contents of a pair with those of another one.
auto operator<=>(const pair& a, const pair& b) -> friend auto defaulted constexpr
Default three-way comparison operator.

Function documentation

template<typename Type1, typename Type2>
void bn::pair<Type1, Type2>::swap(pair& other) constexpr

Exchanges the contents of this pair with those of the other one.

Parameters
other pair to exchange the contents with.

template<typename Type1, typename Type2>
friend void swap(pair& a, pair& b) constexpr

Exchanges the contents of a pair with those of another one.

Parameters
a First pair to exchange the contents with.
b Second pair to exchange the contents with.