std::stack::stack

From Cppreference

Jump to: navigation, search
explicit stack( const Container& cont = Container() );
explicit stack( const Container& cont );
(1) (pre-C++11 version)
(C++11 version)

explicit stack( Container&& cont = Container() );
(2) (C++11 feature)
stack( const stack& other );
(3)
stack( stack&& other );
(4) (C++11 feature)
template< class Allocator >
explicit stack( const Allocator& alloc );
(5) (C++11 feature)
template< class Allocator >
stack( const Container& cont, const Allocator& alloc );
(6) (C++11 feature)
template< class Allocator >
stack( Container&& cont, const Allocator& alloc );
(7) (C++11 feature)
template< class Allocator >
stack( const stack& other, const Allocator& alloc );
(8) (C++11 feature)
template< class Allocator >
stack( stack&& other, const Allocator& alloc );
(9) (C++11 feature)

Constructs new underlying container of the container adaptor from a variety of data sources.

1) Constructs the underlying container c with the contents of cont. Effectively calls c(cont).

2) Constructs the underlying container c with the contents of cont using move semantics. Effectively calls c(std::move(cont)). Since cont has default value of Container(), this constructor can be used as default constructor.

3) Copy constructor. The adaptor is constructed with the contents of other. Effectively calls c(other.c). (implicitly declared)

4) Move constructor. The adaptor is constructed with the contents of other using move semantics. Effectively calls c(std::move(other.c)). (implicitly declared)


The versions (5-9) of the constructor can be used only if Container uses Allocator type as its allocator. Specifically, these versions of the constructor participate in the overload resolution only if {{{1}}}.

5) Constructs the underlying container using alloc as allocator. Effectively calls c(alloc).

6) Constructs the underlying container with the contents of cont and using alloc as allocator. Effectively calls c(cont, alloc).

7) Constructs the underlying container with the contents of cont using move semantics while utilising alloc as allocator. Effectively calls c(std::move(cont), alloc).

8) Constructs the adaptor with the contents of other and using alloc as allocator. Effectively calls c(athor.c, alloc).

9) Constructs the adaptor with the contents of other using move semantics while utilising alloc as allocator. Effectively calls c(std::move(other.c), alloc).

Contents

[edit] Parameters

alloc - allocator to use for all memory allocations of the underlying container
other - another container adaptor to be used as source to initialize the underlying container
cont - container to be used as source to initialize the underlying container

[edit] Complexity

[edit] Example

[edit] See also

operator=
assigns values to the container adaptor
(public member function)