[#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, holding `first` and `second` values of (template parameter) type `PARAM_1` and `PARAM_2` respectively. [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, holding `first` and `second` values of (template parameter) type `PARAM_1` and `PARAM_2` respectively. This method requires that `T1` and `T2` be convertible from `PARAM_1` and `PARAM_2`, respectively. [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` that has the same value as the specified `rhs` pair proxy. The behavior is undefined unless `T1` is constructible from `PARAM_1` and `T2` is constructible from from `PARAM_2`. [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` with the `first` member initialized to the specified `a` value and the `second` member initialized to the specified `b` value. Optionally specify a `basicAllocator`, used to supply memory for each of `first` and `second` when its type (template parameter `T1` or `T2`, respectively) uses `bslma`‐style allocators. This method requires that `T1` and `T2` be `copy‐constructible`. [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..._]# Construct a `pair` having the same value as that of the specified `original` pair. Optionally specify a `basicAllocator`, used to supply memory for each of `first` and `second` when its type (template parameter `T1` or `T2`, respectively) uses `bslma`‐style allocators. Note that the copy constructor is implicitly declared (if `T1` and `T2` are both `copy‐constructible`) by compilers that do not support defaulted declarations. [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..._]# Construct a pair having the same value as that of the specified `original` using the specified `basicAllocator` to supply memory for each of `first` and `second` when its type (template parameter `T1` or `T2`, respectively) uses `bslma`‐style allocators. Note that `original` is left in a valid but unspecified state. Also note that this method requires that `T1` and `T2` be move‐constructible. Note this this constructor will _not_ be deleted when the implicitly declared move constructor is deleted, and will produce an error when it is called in such cases. [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 the specified `other` 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"] ---- 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 specified `other` 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"] ---- 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 specified `other` rvalue 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"] ---- 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` with the `first` member initialized to the specified `a` value and the `second` member initialized to the specified `b` value. [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..._]# Create a `pair` from piece‐wise construction of `first` and `second` values by forwarding in order the elements in the specified `first_args` and `second_args` tuples to the corresponding constructor of (template parameter) types `T1` and `T2`, respectively. Optionally specify a `basicAllocator`, used to supply memory for each of `first` and `second` when its type (template parameter `T1` or `T2`, respectively) uses `bslma`‐style allocators. Allocators can also be passed as tuple members straight to `T1` or `T2` (or both) constructors using the first version (but use of the second version for this approach will result in a compile‐time error). This method requires that `T1` and `T2` be constructible from (the variable number of template parameters) `ARGS_1` and `ARGS_2` respectively. [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, std::tuple<ARGS_1...> first_args, std::tuple<ARGS_2...> second_args); ---- [.small]#xref:bsl/pair-0b/2constructor-096.adoc[_» more..._]# Construct a `pair` with the `first` member initialized to the specified `a` value and the `second` member initialized to the specified `b` value, using the specified `basicAllocator` to supply memory for each member when its type uses `bslma`‐style allocators. [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, 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..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#