[#bsl-stack-05-2constructor-010]
= xref:bsl.adoc[bsl]::xref:bsl/stack-05.adoc[stack]::stack
:relfileprefix: ../../
:mrdocs:

Constructors

== Synopses

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

Create an empty stack&period; No allocator will be provided to the underlying container&period; That container&apos;s memory allocation will be provided by the default allocator of its type&period;


[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&period;&period;&period;_]#

Create a stack having the value of the specified `original`&period; The currently installed default allocator is used to supply memory&period;


[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&period;&period;&period;_]#

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&period; The allocator associated with `container` is propagated for use in the new stack&period; `container` is left in a valid but unspecified state&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
explicit
xref:bsl/stack-05/2constructor-0e2.adoc[stack](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;CONTAINER&gt;] container);
----

[.small]#xref:bsl/stack-05/2constructor-0e2.adoc[_» more&period;&period;&period;_]#

Create a stack having the value of the specified `original` by moving the contents of `original` to the new stack&period; The allocator associated with `original` is propagated for use in the new stack&period; `original` is left in a valid but unspecified state&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:bsl/stack-05/2constructor-04e.adoc[stack](xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;stack&gt;] original);
----

[.small]#xref:bsl/stack-05/2constructor-04e.adoc[_» more&period;&period;&period;_]#

Create a stack whose underlying container has the value of the specified `container`&period; The currently installed default allocator is used to supply memory&period;


[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&period;&period;&period;_]#

Create a stack passing the specified `first` and `last` to the constructor of the underlying container&period; Optionally specify an `allocator` used to supply memory&period; If `allocator` is not specified, a default&hyphen;constructed object of the (template parameter) type `ALLOCATOR` is used&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class INPUT&lowbar;ITER&gt;
xref:bsl/stack-05/2constructor-05c.adoc[stack](
    INPUT&lowbar;ITER first,
    INPUT&lowbar;ITER last);
----

[.small]#xref:bsl/stack-05/2constructor-05c.adoc[_» more&period;&period;&period;_]#

Create a stack from the elements of the specifed `range`&period; Optionally specify an `allocator` used to supply memory&period; If `allocator` is not specified, a default&hyphen;constructed object of the (template parameter) type `t&lowbar;ALLOCATOR` is used&period; 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`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class t&lowbar;RANGE&gt;
xref:bsl/stack-05/2constructor-049.adoc[stack](
    std::from&lowbar;range&lowbar;t,
    t&lowbar;RANGE&& range);
----

[.small]#xref:bsl/stack-05/2constructor-049.adoc[_» more&period;&period;&period;_]#

Create an empty stack, and use the specified `basicAllocator` to supply memory&period; If `CONTAINER&colon;&colon;allocator&lowbar;type` does not exist, this constructor may not be used&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOCATOR&gt;
explicit
xref:bsl/stack-05/2constructor-0f.adoc[stack](
    ALLOCATOR const& basicAllocator,
    ALLOCATOR* = 0)
requires bsl&colon;&colon;uses&lowbar;allocator&lt;CONTAINER, ALLOCATOR&gt;&colon;&colon;value;
----

[.small]#xref:bsl/stack-05/2constructor-0f.adoc[_» more&period;&period;&period;_]#

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&hyphen;extended move constructor of `CONTAINER&period; `container&apos; is left in a valid but unspecified state&period; A `bslma&colon;&colon;Allocator &ast;` can be supplied for `basicAllocator` if the (template parameter) `ALLOCATOR` is `bsl&colon;&colon;allocator` (the default)&period; This method assumes that `CONTAINER` has a move constructor&period; If `CONTAINER&colon;&colon;allocator&lowbar;type` does not exist, this constructor may not be used&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOCATOR&gt;
xref:bsl/stack-05/2constructor-050.adoc[stack](
    xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;CONTAINER&gt;] container,
    ALLOCATOR const& basicAllocator,
    ALLOCATOR* = 0)
requires bsl&colon;&colon;uses&lowbar;allocator&lt;CONTAINER, ALLOCATOR&gt;&colon;&colon;value;
----

[.small]#xref:bsl/stack-05/2constructor-050.adoc[_» more&period;&period;&period;_]#

Create a stack having the value of the specified `original` (on entry) that uses `basicAllocator` to supply memory by using the allocator&hyphen;extended moved constructor of `CONTAINER`&period; `original` is left in a valid but unspecified state&period; Note that a `bslma&colon;&colon;Allocator &ast;` can be supplied for `basicAllocator` if the (template parameter) `ALLOCATOR` is `bsl&colon;&colon;allocator` (the default)&period; Also note that this method assumes that `CONTAINER` has a move constructor&period; Also note that if `CONTAINER&colon;&colon;allocator&lowbar;type` does not exist, this constructor may not be used&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOCATOR&gt;
xref:bsl/stack-05/2constructor-06.adoc[stack](
    xref:BloombergLP/bslmf/MovableRef.adoc[BloombergLP::bslmf::MovableRef&lt;stack&gt;] original,
    ALLOCATOR const& basicAllocator,
    ALLOCATOR* = 0)
requires bsl&colon;&colon;uses&lowbar;allocator&lt;CONTAINER, ALLOCATOR&gt;&colon;&colon;value;
----

[.small]#xref:bsl/stack-05/2constructor-06.adoc[_» more&period;&period;&period;_]#

Create a stack whose underlying container has the value of the specified `container`, and use the specified `basicAllocator` to supply memory&period; If `CONTAINER&colon;&colon;allocator&lowbar;type` does not exist, this constructor may not be used&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOCATOR&gt;
xref:bsl/stack-05/2constructor-0c.adoc[stack](
    CONTAINER const& container,
    ALLOCATOR const& basicAllocator,
    ALLOCATOR* = 0)
requires bsl&colon;&colon;uses&lowbar;allocator&lt;CONTAINER, ALLOCATOR&gt;&colon;&colon;value;
----

[.small]#xref:bsl/stack-05/2constructor-0c.adoc[_» more&period;&period;&period;_]#

Create a stack having the value of the specified stack `original` and use the specified `basicAllocator` to supply memory&period; If `CONTAINER&colon;&colon;allocator&lowbar;type` does not exist, this constructor may not be used&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class ALLOCATOR&gt;
xref:bsl/stack-05/2constructor-043.adoc[stack](
    xref:bsl/stack-05.adoc[stack] const& original,
    ALLOCATOR const& basicAllocator,
    ALLOCATOR* = 0)
requires bsl&colon;&colon;uses&lowbar;allocator&lt;CONTAINER, ALLOCATOR&gt;&colon;&colon;value;
----

[.small]#xref:bsl/stack-05/2constructor-043.adoc[_» more&period;&period;&period;_]#

Same as the related overload above for `stack`&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class INPUT&lowbar;ITER,
    class ALLOCATOR&gt;
xref:bsl/stack-05/2constructor-08.adoc[stack](
    INPUT&lowbar;ITER first,
    INPUT&lowbar;ITER last,
    ALLOCATOR const& allocator,
    ALLOCATOR* = 0)
requires bsl&colon;&colon;uses&lowbar;allocator&lt;CONTAINER, ALLOCATOR&gt;&colon;&colon;value;
----

[.small]#xref:bsl/stack-05/2constructor-08.adoc[_» more&period;&period;&period;_]#

Same as the preceding overload&period;


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;RANGE,
    class t&lowbar;ALLOCATOR&gt;
xref:bsl/stack-05/2constructor-015.adoc[stack](
    std::from&lowbar;range&lowbar;t,
    t&lowbar;RANGE&& range,
    t&lowbar;ALLOCATOR const& allocator,
    t&lowbar;ALLOCATOR* = 0)
requires bsl&colon;&colon;uses&lowbar;allocator&lt;CONTAINER,t&lowbar;ALLOCATOR&gt;&colon;&colon;value;
----

[.small]#xref:bsl/stack-05/2constructor-015.adoc[_» more&period;&period;&period;_]#


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