[#bsl-pair-0b] = xref:bsl.adoc[bsl]::pair :relfileprefix: ../ :mrdocs: A pair of public data members, `first` and `second`, that supports `bslma` allocators. == Synopsis Declared in `<bslstl_pair.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class T1, class T2> class pair : public xref:bsl/Pair_First-00.adoc[Pair_First<T1>] , public xref:bsl/Pair_Second-05e.adoc[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 [cols="1,4"] |=== | Name| Description | `xref:bsl/Pair_First-00.adoc[Pair_First<T1>]` | Component‐private base holding and constructing a pair's `first` member. | `xref:bsl/Pair_Second-05e.adoc[Pair_Second<T2>]` | Component‐private base holding and constructing a pair's `second` member. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:bsl/pair-0b/first_type.adoc[`first_type`] | This `typedef` is an alias to the type of the `first` data member. | xref:bsl/pair-0b/second_type.adoc[`second_type`] | This `typedef` is an alias to the type of the `second` data member. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/pair-0b/2constructor-089.adoc[`pair`] [.small]#[constructor]# | Constructors | xref:bsl/pair-0b/operator_assign-04.adoc[`operator=`] | Assignment operators | xref:bsl/pair-0b/swap.adoc[`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. | xref:bsl/pair-0b/2conversion-057.adoc[`operator std::tuple<PARAM_1&, PARAM_2&>`] | Return an `std::tuple` object, holding references that provide modifiable access to the members of this object. | xref:bsl/pair-0b/2conversion-0e.adoc[`operator std::tuple<PARAM_1&, decltype(std::ignore)&>`] | Convert to an `std::tuple` whose second element is `std::ignore`. | xref:bsl/pair-0b/2conversion-054.adoc[`operator std::tuple<decltype(std::ignore)&, PARAM_2&>`] | Convert to an `std::tuple` whose first element is `std::ignore`. | xref:bsl/pair-0b/2conversion-0c.adoc[`operator std::tuple<decltype(std::ignore)&, decltype(std::ignore)&>`] | Convert to an `std::tuple` whose elements are both `std::ignore`. |=== == Using Declarations [cols="1,4"] |=== | Name| Description | xref:bsl/pair-0b/first.adoc[`first`] | Bring the `first` data member from `FirstBase` into scope. | xref:bsl/pair-0b/second.adoc[`second`] | Bring the `second` data member from `SecondBase` into scope. |=== == Protected Data Members [cols="1,4"] |=== | Name| Description | xref:bsl/Pair_First-00/first.adoc[`first`] | First element of the pair. | xref:bsl/Pair_Second-05e/second.adoc[`second`] | Second element of the pair. |=== == Deduction Guides [cols="1,4"] |=== | Name| Description | xref:bsl/pair-04.adoc[`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`. | xref:bsl/pair-09.adoc[`pair<T1, T2>`] | Deduce the specified types `T1` and `T2` from the corresponding types supplied to the constructor of `pair`. | xref:bsl/pair-03.adoc[`pair<T1, T2>`] | Deduce `T1` and `T2` from the `bsl::pair` and allocator passed to `pair`. | xref:bsl/pair-05.adoc[`pair<T1, T2>`] | Deduce `T1` and `T2` from the `std::pair` and allocator passed to `pair`. | xref:bsl/pair-0f.adoc[`pair<T1, T2>`] | Deduce `T1` and `T2` from the values and allocator passed to `pair`. |=== == Non-Member Functions [cols="1,4"] |=== | Name| Description | xref:bsl/get-00c.adoc[`get`] | Return a modifiable reference to the `INDEX`th element of `p`. | xref:bsl/get-034.adoc[`get`] | Return a non‐modifiable rvalue reference to the element of `p` of `TYPE`. | xref:bsl/get-052.adoc[`get`] | Return a non‐modifiable reference to the `INDEX`th element of `p`. | xref:bsl/get-08.adoc[`get`] | Return a non‐modifiable reference to the element of `p` having type `TYPE`. | xref:bsl/get-0b0.adoc[`get`] | Return a modifiable reference to the element of `p` having type `TYPE`. | xref:bsl/get-0b3.adoc[`get`] | Return a modifiable rvalue reference to the `INDEX`th element of `p`. | xref:bsl/get-0e8.adoc[`get`] | Return a modifiable rvalue reference to the element of `p` of type `TYPE`. | xref:bsl/operator_3way-05.adoc[`operator<=>`] | Compare the specified `lhs` and `rhs` pairs lexicographically. | xref:bsl/operator_eq-0cf.adoc[`operator==`] | Return `true` if the specified `lhs` and `rhs` pairs have the same value. | xref:bsl/swap-0ce.adoc[`swap`] | Swap the values of the specified `a` and `b` pairs. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#