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

Name

Description

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

Name

Description

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

Name

Description

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

Name

Description

first

Bring the first data member from FirstBase into scope.

second

Bring the second data member from SecondBase into scope.

Protected Data Members

Name

Description

first

First element of the pair.

second

Second element of the pair.

Deduction Guides

Name

Description

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

Name

Description

get

Return a modifiable reference to the INDEX`th element of `p.

get

Return a non‐modifiable rvalue reference to the element of p of TYPE.

get

Return a non‐modifiable reference to the INDEX`th element of `p.

get

Return a non‐modifiable reference to the element of p having type TYPE.

get

Return a modifiable reference to the element of p having type TYPE.

get

Return a modifiable rvalue reference to the INDEX`th element of `p.

get

Return 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.

swap

Swap the values of the specified a and b pairs.

Created with MrDocs