bsl::pair

A pair of public data members, first and second, that supports bslma allocators.

Synopsis

Declared in <bslstl_pair.h>

template<
    class T1,
    class T2>
class pair
    : public Pair_First<T1>
    , public Pair_Second<T2>

Description

The class template pair provides a pair of public data members, first and second, of type T1 and T2 respectively. If either T1 or T2 uses bslma::Allocator for memory management, then provide an optional bslma::Allocator argument for each constructor, to be passed through to the constructors of first and/or second as appropriate. The interface to this class is identical to the standard std::pair except for the addition of the allocators. Note that the implementation of this class provides first and second through multiple base classes in order to simplify construction of each member when allowing for the various rules for passing allocators in C++11.

Base Classes

NameDescription
Pair_First<T1>Component-private base holding and constructing a pair's first member.
Pair_Second<T2>Component-private base holding and constructing a pair's second member.

Type Aliases

NameDescription
first_type This typedef is an alias to the type of the first data member.
second_type This typedef is an alias to the type of the second data member.

Member Functions

NameDescription
pair [constructor]Constructors
operator= Assignment operators
swap Swap the value of this pair with the value of the specified other pair by applying swap to each of the first and second pair fields.
operator std::tuple<PARAM_1&, PARAM_2&> Return an std::tuple object, holding references that provide modifiable access to the members of this object.
operator std::tuple<PARAM_1&, decltype(std::ignore)&> Convert to an std::tuple whose second element is std::ignore.
operator std::tuple<decltype(std::ignore)&, PARAM_2&> Convert to an std::tuple whose first element is std::ignore.
operator std::tuple<decltype(std::ignore)&, decltype(std::ignore)&> Convert to an std::tuple whose elements are both std::ignore.

Using Declarations

NameDescription
first Bring the first data member from FirstBase into scope.
second Bring the second data member from SecondBase into scope.

Protected Data Members

NameDescription
first First element of the pair.
second Second element of the pair.

Deduction Guides

NameDescription
pair<T1, T2> Deduce the specified types T1 and T2 from the corresponding template parameters of the std::pair supplied to the constructor of pair.
pair<T1, T2> Deduce the specified types T1 and T2 from the corresponding types supplied to the constructor of pair.
pair<T1, T2> Deduce T1 and T2 from the bsl::pair and allocator passed to pair.
pair<T1, T2> Deduce T1 and T2 from the std::pair and allocator passed to pair.
pair<T1, T2> Deduce T1 and T2 from the values and allocator passed to pair.

Non-Member Functions

NameDescription
getReturn a modifiable reference to the INDEXth element of p.
getReturn a non-modifiable rvalue reference to the element of p of TYPE.
getReturn a non-modifiable reference to the INDEXth element of p.
getReturn a non-modifiable reference to the element of p having type TYPE.
getReturn a modifiable reference to the element of p having type TYPE.
getReturn a modifiable rvalue reference to the INDEXth element of p.
getReturn a modifiable rvalue reference to the element of p of type TYPE.
operator<=>Compare the specified lhs and rhs pairs lexicographically.
operator==Return true if the specified lhs and rhs pairs have the same value.
swapSwap the values of the specified a and b pairs.