std::dynarray::dynarray

From cppreference.com
< cpp‎ | container‎ | dynarray
explicit dynarray( size_type count );
(1) (since C++14)
template< class Alloc >
dynarray( size_type count, const Alloc& alloc );
(2) (since C++14)
dynarray( size_type count, const T& value );
(3) (since C++14)
template< class Alloc >
dynarray( size_type count, const T& value, const Alloc& alloc );
(4) (since C++14)
dynarray( const dynarray& other );
(5) (since C++14)
template< class Alloc >
dynarray( const dynarray& other, const Alloc& alloc );
(6) (since C++14)
dynarray( std::initializer_list<T> init );
(7) (since C++14)
template< class Alloc >
dynarray( std::initializer_list<T> init, const Alloc& alloc );
(8) (since C++14)

Constructs a new container from a variety of data sources, optionally using user supplied allocator alloc. If an allocator is provided, all memory allocations are done though it. Otherwise, the memory is allocated from an unspecified source, which may, or may not, invoke the global operator new. This way, additional optimization opportunities are possible, for example, using stack-based allocation.

1-2) Constructs the container with count default-initialized (or constructed by specified allocator) instances of T. No copies are made.
3-4) Constructs the container with count copies of elements with value value. T must meet the requirements of CopyConstructible.
5-6) Copy-constructor. Constructs the container with the copy of the contents of other. T must meet the requirements of CopyConstructible.
7-8) Constructs the container with the contents of the initializer list init.

Contents

[edit] Parameters

alloc - allocator to use for the memory allocations of this container
count - the size of the container
value - the value to initialize elements of the container with
other - another container to be used as source to initialize the elements of the container with
init - initializer list to initialize the elements of the container with
Type requirements
-
Alloc must meet the requirements of Allocator.

[edit] Complexity

1-4) Linear in count
5-6) Linear in other.size()
7-8) Linear in size of init

[edit] Exceptions

1-4) std::bad_alloc if there's insufficient memory. std::bad_array_length if count is above the implementation-defined limits.
5-8) std::bad_alloc if there's insufficient memory.

[edit] Example