[#bsl-pair-0b]
= xref:bsl.adoc[bsl]::pair
:relfileprefix: ../
:mrdocs:

A pair of public data members, `first` and `second`, that supports `bslma` allocators&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;pair&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class T1,
    class T2&gt;
class pair
    : public xref:bsl/Pair_First-00.adoc[Pair&lowbar;First&lt;T1&gt;]
    , public xref:bsl/Pair_Second-05e.adoc[Pair&lowbar;Second&lt;T2&gt;]
----

== Description

The class template `pair` provides a pair of public data members, `first` and `second`, of type `T1` and `T2` respectively&period; If either `T1` or `T2` uses `bslma&colon;&colon;Allocator` for memory management, then provide an optional `bslma&colon;&colon;Allocator` argument for each constructor, to be passed through to the constructors of `first` and&sol;or `second` as appropriate&period; The interface to this class is identical to the standard `std&colon;&colon;pair` except for the addition of the allocators&period; 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&plus;&plus;11&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:bsl/Pair_First-00.adoc[Pair&lowbar;First&lt;T1&gt;]`
| Component&hyphen;private base holding and constructing a pair&apos;s `first` member&period;
| `xref:bsl/Pair_Second-05e.adoc[Pair&lowbar;Second&lt;T2&gt;]`
| Component&hyphen;private base holding and constructing a pair&apos;s `second` member&period;
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:bsl/pair-0b/first_type.adoc[`first&lowbar;type`] 
| This `typedef` is an alias to the type of the `first` data member&period;
| xref:bsl/pair-0b/second_type.adoc[`second&lowbar;type`] 
| This `typedef` is an alias to the type of the `second` data member&period;
|===


== 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&equals;`] 
| 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&period;
| xref:bsl/pair-0b/2conversion-057.adoc[`operator std::tuple&lt;PARAM&lowbar;1&, PARAM&lowbar;2&&gt;`] 
| Return an `std&colon;&colon;tuple` object, holding references that provide modifiable access to the members of this object&period;
| xref:bsl/pair-0b/2conversion-0e.adoc[`operator std::tuple&lt;PARAM&lowbar;1&, decltype(std&colon;&colon;ignore)&&gt;`] 
| Convert to an `std&colon;&colon;tuple` whose second element is `std&colon;&colon;ignore`&period;
| xref:bsl/pair-0b/2conversion-054.adoc[`operator std::tuple&lt;decltype(std&colon;&colon;ignore)&, PARAM&lowbar;2&&gt;`] 
| Convert to an `std&colon;&colon;tuple` whose first element is `std&colon;&colon;ignore`&period;
| xref:bsl/pair-0b/2conversion-0c.adoc[`operator std::tuple&lt;decltype(std&colon;&colon;ignore)&, decltype(std&colon;&colon;ignore)&&gt;`] 
| Convert to an `std&colon;&colon;tuple` whose elements are both `std&colon;&colon;ignore`&period;
|===


== Using Declarations

[cols="1,4"]
|===
| Name| Description
| xref:bsl/pair-0b/first.adoc[`first`] 
| Bring the `first` data member from `FirstBase` into scope&period;
| xref:bsl/pair-0b/second.adoc[`second`] 
| Bring the `second` data member from `SecondBase` into scope&period;
|===


== Protected Data Members

[cols="1,4"]
|===
| Name| Description
| xref:bsl/Pair_First-00/first.adoc[`first`] 
| First element of the pair&period;
| xref:bsl/Pair_Second-05e/second.adoc[`second`] 
| Second element of the pair&period;
|===


== Deduction Guides

[cols="1,4"]
|===
| Name| Description
| xref:bsl/pair-04.adoc[`pair&lt;T1, T2&gt;`] 
| Deduce the specified types `T1` and `T2` from the corresponding template parameters of the `std&colon;&colon;pair` supplied to the constructor of `pair`&period;
| xref:bsl/pair-09.adoc[`pair&lt;T1, T2&gt;`] 
| Deduce the specified types `T1` and `T2` from the corresponding types supplied to the constructor of `pair`&period;
| xref:bsl/pair-03.adoc[`pair&lt;T1, T2&gt;`] 
| Deduce `T1` and `T2` from the `bsl&colon;&colon;pair` and allocator passed to `pair`&period;
| xref:bsl/pair-05.adoc[`pair&lt;T1, T2&gt;`] 
| Deduce `T1` and `T2` from the `std&colon;&colon;pair` and allocator passed to `pair`&period;
| xref:bsl/pair-0f.adoc[`pair&lt;T1, T2&gt;`] 
| Deduce `T1` and `T2` from the values and allocator passed to `pair`&period;
|===


== 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`&period;
| xref:bsl/get-034.adoc[`get`]
| Return a non&hyphen;modifiable rvalue reference to the element of `p` of `TYPE`&period;
| xref:bsl/get-052.adoc[`get`]
| Return a non&hyphen;modifiable reference to the `INDEX`th element of `p`&period;
| xref:bsl/get-08.adoc[`get`]
| Return a non&hyphen;modifiable reference to the element of `p` having type `TYPE`&period;
| xref:bsl/get-0b0.adoc[`get`]
| Return a modifiable reference to the element of `p` having type `TYPE`&period;
| xref:bsl/get-0b3.adoc[`get`]
| Return a modifiable rvalue reference to the `INDEX`th element of `p`&period;
| xref:bsl/get-0e8.adoc[`get`]
| Return a modifiable rvalue reference to the element of `p` of type `TYPE`&period;
| xref:bsl/operator_3way-05.adoc[`operator&lt;&equals;&gt;`]
| Compare the specified `lhs` and `rhs` pairs lexicographically&period;
| xref:bsl/operator_eq-0cf.adoc[`operator&equals;&equals;`]
| Return `true` if the specified `lhs` and `rhs` pairs have the same value&period;
| xref:bsl/swap-0ce.adoc[`swap`]
| Swap the values of the specified `a` and `b` pairs&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
