[#bsl-pair-0b-2constructor-089] = xref:bsl.adoc[bsl]::xref:bsl/pair-0b.adoc[pair]::pair :relfileprefix: ../../ :mrdocs: Constructors == Synopses Declared in `<bslstl_pair.h>` Construct a `pair` with the `first` and `second` members initialized to default values. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- constexpr xref:bsl/pair-0b/2constructor-08c.adoc[pair]() = default; ---- [.small]#xref:bsl/pair-0b/2constructor-08c.adoc[_» more..._]# Construct a `pair` from the specified `other` pair. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2, class = void> requires std::is_constructible<T1, const PARAM_1&>::value && std::is_constructible<T2, const PARAM_2&>::value constexpr xref:bsl/pair-0b/2constructor-041.adoc[pair](xref:bsl/pair-0b.adoc[pair<PARAM_1, PARAM_2>] const& other); ---- [.small]#xref:bsl/pair-0b/2constructor-041.adoc[_» more..._]# Construct a `pair` from the specified `other` rvalue pair. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2, class = void> requires bsl::is_convertible<PARAM_1, T1>::value && bsl::is_convertible<PARAM_2, T2>::value constexpr xref:bsl/pair-0b/2constructor-01.adoc[pair](xref:bsl/pair-0b.adoc[pair<PARAM_1, PARAM_2>]&& other); ---- [.small]#xref:bsl/pair-0b/2constructor-01.adoc[_» more..._]# Construct a default `pair`, using the specified `basicAllocator` to supply memory for each member when its type uses `bslma`‐style allocators. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:bsl/pair-0b/2constructor-0d6.adoc[pair](xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-0d6.adoc[_» more..._]# Create a `pair` having the same value as the specified `rhs` pair proxy. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2> constexpr xref:bsl/pair-0b/2constructor-0f.adoc[pair](xref:BloombergLP/bslma/ManagedPtr_PairProxy.adoc[BloombergLP::bslma::ManagedPtr_PairProxy<PARAM_1, PARAM_2>] const& rhs); ---- [.small]#xref:bsl/pair-0b/2constructor-0f.adoc[_» more..._]# Same as the preceding overload. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2, class = void> requires std::is_constructible<T1, const PARAM_1&>::value && std::is_constructible<T2, const PARAM_2&>::value constexpr xref:bsl/pair-0b/2constructor-0a.adoc[pair](std::pair<PARAM_1, PARAM_2> const& other); ---- [.small]#xref:bsl/pair-0b/2constructor-0a.adoc[_» more..._]# Same as the constructor taking `pair<PARAM_1, PARAM_2>&&`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2, class = void> requires bsl::is_convertible<PARAM_1, T1>::value && bsl::is_convertible<PARAM_2, T2>::value constexpr xref:bsl/pair-0b/2constructor-03.adoc[pair](std::pair<PARAM_1, PARAM_2>&& other); ---- [.small]#xref:bsl/pair-0b/2constructor-03.adoc[_» more..._]# Construct a `pair` from the specified `a` and `b` values. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- constexpr xref:bsl/pair-0b/2constructor-099e.adoc[pair]( bsl::add_lvalue_reference<T1 const>::type a, bsl::add_lvalue_reference<T2 const>::type b); ---- [.small]#xref:bsl/pair-0b/2constructor-099e.adoc[_» more..._]# Copy `original` using `basicAllocator` to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/pair-0b/2constructor-0c.adoc[pair]( xref:bsl/pair-0b.adoc[pair] const& original, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-0c.adoc[_» more..._]# Move `original` using `basicAllocator` to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/pair-0b/2constructor-099c.adoc[pair]( xref:bsl/pair-0b.adoc[pair]&& original, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-099c.adoc[_» more..._]# Construct a `pair` from `other`, using `basicAllocator`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2> xref:bsl/pair-0b/2constructor-02f.adoc[pair]( xref:bsl/pair-0b.adoc[pair<PARAM_1, PARAM_2>] const& other, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-02f.adoc[_» more..._]# Construct a `pair` from the `std::pair` `other`, using `basicAllocator`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2> xref:bsl/pair-0b/2constructor-020.adoc[pair]( std::pair<PARAM_1, PARAM_2> const& other, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-020.adoc[_» more..._]# Construct a `pair` from the specified rvalue `other` pair. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2> xref:bsl/pair-0b/2constructor-0e.adoc[pair]( xref:bsl/pair-0b.adoc[pair<PARAM_1, PARAM_2>]&& other, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-0e.adoc[_» more..._]# Construct a `pair` from the rvalue `other`, using `basicAllocator`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2> xref:bsl/pair-0b/2constructor-06.adoc[pair]( std::pair<PARAM_1, PARAM_2>&& other, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-06.adoc[_» more..._]# Construct a `pair` from the specified `a` and `b` values. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2, class = void> requires std::is_constructible<T1, PARAM_1>::value && std::is_constructible<T2, PARAM_2>::value && !(bsl::is_pointer<bsl::remove_reference_t<PARAM_2>>::value && bsl::is_convertible<PARAM_2, BloombergLP::bslma::Allocator *>::value) constexpr xref:bsl/pair-0b/2constructor-0db.adoc[pair]( PARAM_1&& a, PARAM_2&& b); ---- [.small]#xref:bsl/pair-0b/2constructor-0db.adoc[_» more..._]# Create a `pair` from the specified `a` and `b` lvalue references. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/pair-0b/2constructor-009.adoc[pair]( bsl::add_lvalue_reference<T1 const>::type a, bsl::add_lvalue_reference<T2 const>::type b, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-009.adoc[_» more..._]# Construct `first` and `second` piece‐wise from tuples of arguments. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class... ARGS_1, class... ARGS_2> xref:bsl/pair-0b/2constructor-096.adoc[pair]( std::piecewise_construct_t tag, std::tuple<ARGS_1...> first_args, std::tuple<ARGS_2...> second_args); ---- [.small]#xref:bsl/pair-0b/2constructor-096.adoc[_» more..._]# Construct a `pair` from `a` and `b`, using `basicAllocator`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class PARAM_1, class PARAM_2> xref:bsl/pair-0b/2constructor-00c.adoc[pair]( PARAM_1&& a, PARAM_2&& b, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-00c.adoc[_» more..._]# Same as the preceding constructor, using the specified `basicAllocator` to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class... ARGS_1, class... ARGS_2> xref:bsl/pair-0b/2constructor-04f.adoc[pair]( std::piecewise_construct_t tag, std::tuple<ARGS_1...> first_args, std::tuple<ARGS_2...> second_args, xref:BloombergLP/bslma/Allocator.adoc[BloombergLP::bslma::Allocator]* basicAllocator); ---- [.small]#xref:bsl/pair-0b/2constructor-04f.adoc[_» more..._]# == Parameters [cols="1,4"] |=== | Name| Description | *other* | pair whose members initialize this pair's members | *basicAllocator* | allocator used to supply memory | *rhs* | pair proxy whose members initialize this pair's members | *a* | value copied into the `first` member | *b* | value copied into the `second` member | *original* | pair whose value is copied | *tag* | tag selecting piece‐wise construction | *first_args* | tuple of arguments forwarded to the constructor of `T1` | *second_args* | tuple of arguments forwarded to the constructor of `T2` |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#