[#bsl-stack-05-2constructor-010] = xref:bsl.adoc[bsl]::xref:bsl/stack-05.adoc[stack]::stack :relfileprefix: ../../ :mrdocs: Constructors == Synopses Declared in `<bslstl_stack.h>` Create an empty stack. No allocator will be provided to the underlying container. That container's memory allocation will be provided by the default allocator of its type. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:bsl/stack-05/2constructor-0e6.adoc[stack](); ---- [.small]#xref:bsl/stack-05/2constructor-0e6.adoc[_» more..._]# Create a stack having the value of the specified `original`. The currently installed default allocator is used to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/stack-05/2constructor-01d.adoc[stack](xref:bsl/stack-05.adoc[stack] const& original); ---- [.small]#xref:bsl/stack-05/2constructor-01d.adoc[_» more..._]# Create a stack whose underlying container has the value of the specified `container` (on entry) by moving the contents of `container` to the new stack. The allocator associated with `container` is propagated for use in the new stack. `container` is left in a valid but unspecified state. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:bsl/stack-05/2constructor-0e2.adoc[stack](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<CONTAINER>] container); ---- [.small]#xref:bsl/stack-05/2constructor-0e2.adoc[_» more..._]# Create a stack having the value of the specified `original` by moving the contents of `original` to the new stack. The allocator associated with `original` is propagated for use in the new stack. `original` is left in a valid but unspecified state. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- xref:bsl/stack-05/2constructor-04e.adoc[stack](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<stack>] original); ---- [.small]#xref:bsl/stack-05/2constructor-04e.adoc[_» more..._]# Create a stack whose underlying container has the value of the specified `container`. The currently installed default allocator is used to supply memory. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- explicit xref:bsl/stack-05/2constructor-03.adoc[stack](CONTAINER const& container); ---- [.small]#xref:bsl/stack-05/2constructor-03.adoc[_» more..._]# Create a stack passing the specified `first` and `last` to the constructor of the underlying container. Optionally specify an `allocator` used to supply memory. If `allocator` is not specified, a default‐constructed object of the (template parameter) type `ALLOCATOR` is used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class INPUT_ITER> xref:bsl/stack-05/2constructor-05c.adoc[stack]( INPUT_ITER first, INPUT_ITER last); ---- [.small]#xref:bsl/stack-05/2constructor-05c.adoc[_» more..._]# Create a stack from the elements of the specifed `range`. Optionally specify an `allocator` used to supply memory. If `allocator` is not specified, a default‐constructed object of the (template parameter) type `t_ALLOCATOR` is used. Note that `range` must meet the requirements of an input range and the values from `range` must have a type matching or convertible to (template parameter) `VALUE`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class t_RANGE> xref:bsl/stack-05/2constructor-049.adoc[stack]( std::from_range_t, t_RANGE&& range); ---- [.small]#xref:bsl/stack-05/2constructor-049.adoc[_» more..._]# Create an empty stack, and use the specified `basicAllocator` to supply memory. If `CONTAINER::allocator_type` does not exist, this constructor may not be used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOCATOR> explicit xref:bsl/stack-05/2constructor-0f.adoc[stack]( ALLOCATOR const& basicAllocator, ALLOCATOR* = 0) requires bsl::uses_allocator<CONTAINER, ALLOCATOR>::value; ---- [.small]#xref:bsl/stack-05/2constructor-0f.adoc[_» more..._]# Create a stack whose underlying container has the value of the specified `container` (on entry) that uses `basicAllocator` to supply memory by using the allocator‐extended move constructor of `CONTAINER. `container' is left in a valid but unspecified state. A `bslma::Allocator *` can be supplied for `basicAllocator` if the (template parameter) `ALLOCATOR` is `bsl::allocator` (the default). This method assumes that `CONTAINER` has a move constructor. If `CONTAINER::allocator_type` does not exist, this constructor may not be used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOCATOR> xref:bsl/stack-05/2constructor-050.adoc[stack]( xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<CONTAINER>] container, ALLOCATOR const& basicAllocator, ALLOCATOR* = 0) requires bsl::uses_allocator<CONTAINER, ALLOCATOR>::value; ---- [.small]#xref:bsl/stack-05/2constructor-050.adoc[_» more..._]# Create a stack having the value of the specified `original` (on entry) that uses `basicAllocator` to supply memory by using the allocator‐extended moved constructor of `CONTAINER`. `original` is left in a valid but unspecified state. Note that a `bslma::Allocator *` can be supplied for `basicAllocator` if the (template parameter) `ALLOCATOR` is `bsl::allocator` (the default). Also note that this method assumes that `CONTAINER` has a move constructor. Also note that if `CONTAINER::allocator_type` does not exist, this constructor may not be used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOCATOR> xref:bsl/stack-05/2constructor-06.adoc[stack]( xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef<stack>] original, ALLOCATOR const& basicAllocator, ALLOCATOR* = 0) requires bsl::uses_allocator<CONTAINER, ALLOCATOR>::value; ---- [.small]#xref:bsl/stack-05/2constructor-06.adoc[_» more..._]# Create a stack whose underlying container has the value of the specified `container`, and use the specified `basicAllocator` to supply memory. If `CONTAINER::allocator_type` does not exist, this constructor may not be used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOCATOR> xref:bsl/stack-05/2constructor-0c.adoc[stack]( CONTAINER const& container, ALLOCATOR const& basicAllocator, ALLOCATOR* = 0) requires bsl::uses_allocator<CONTAINER, ALLOCATOR>::value; ---- [.small]#xref:bsl/stack-05/2constructor-0c.adoc[_» more..._]# Create a stack having the value of the specified stack `original` and use the specified `basicAllocator` to supply memory. If `CONTAINER::allocator_type` does not exist, this constructor may not be used. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<class ALLOCATOR> xref:bsl/stack-05/2constructor-043.adoc[stack]( xref:bsl/stack-05.adoc[stack] const& original, ALLOCATOR const& basicAllocator, ALLOCATOR* = 0) requires bsl::uses_allocator<CONTAINER, ALLOCATOR>::value; ---- [.small]#xref:bsl/stack-05/2constructor-043.adoc[_» more..._]# Same as the related overload above for `stack`. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class INPUT_ITER, class ALLOCATOR> xref:bsl/stack-05/2constructor-08.adoc[stack]( INPUT_ITER first, INPUT_ITER last, ALLOCATOR const& allocator, ALLOCATOR* = 0) requires bsl::uses_allocator<CONTAINER, ALLOCATOR>::value; ---- [.small]#xref:bsl/stack-05/2constructor-08.adoc[_» more..._]# Same as the preceding overload. [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_RANGE, class t_ALLOCATOR> xref:bsl/stack-05/2constructor-015.adoc[stack]( std::from_range_t, t_RANGE&& range, t_ALLOCATOR const& allocator, t_ALLOCATOR* = 0) requires bsl::uses_allocator<CONTAINER,t_ALLOCATOR>::value; ---- [.small]#xref:bsl/stack-05/2constructor-015.adoc[_» more..._]# [.small]#Created with https://www.mrdocs.com[MrDocs]#