![]() |
Home | Libraries | People | FAQ | More |
boost::container::static_vector — A variable-size array container with fixed capacity.
// In header: <boost/container/static_vector.hpp> template<typename T, Capacity, typename Options> class static_vector : public { public: // types typedef ; // The type of elements stored in the container. typedef ; // The unsigned integral type used by the container. typedef ; // The pointers difference type. typedef ; // The pointer type. typedef ; // The const pointer type. typedef ; // The value reference type. typedef ; // The value const reference type. typedef ; // The iterator type. typedef ; // The const iterator type. typedef ; // The reverse iterator type. typedef ; // The const reverse iterator. // construct/copy/destruct () ; (); (, default_init_t); (, ); template<typename Iterator> (, ); (); (static_vector ); (static_vector , ); (static_vector &&, ) ; (); template< C, typename O> (static_vector< ); (static_vector &&) ; template< C, typename O> (static_vector< ); static_vector & (static_vector &); static_vector & (); template< C, typename O> static_vector & (static_vector< ); static_vector & (static_vector &&) ; template< C, typename O> static_vector & (static_vector< ); ~(); // public member functions (static_vector &); template< C, typename O> (static_vector< ); (); (, default_init_t); (, ); () ; (); (); (); (, ); (, ); (, , ); template<typename Iterator> (, , ); (, ); (); (, ); template<typename Iterator> (, ); (); (, ); template< Args> (); template< Args> (, ); () ; (); () ; (); () ; (); () ; (); () ; (); () ; (); () ; () ; () ; () ; () ; () ; () ; () ; () ; () ; () ; () ; () ; () ; () ; () ; () ; // public static functions () ; () ; // public data members static static_capacity; // The capacity/max size of the container. };
static_vector is a sequence container like boost::container::vector with contiguous storage that can change in size, along with the static allocation, low overhead, and fixed capacity of boost::array.
A static_vector is a sequence that supports random access to elements, constant time insertion and removal of elements at the end, and linear time insertion and removal of elements at the beginning or in the middle. The number of elements in a static_vector may vary dynamically up to a fixed capacity because elements are stored within the object itself similarly to an array. However, objects are initialized as they are inserted into static_vector unlike C arrays or std::array which must construct all elements on instantiation. The behavior of static_vector enables the use of statically allocated elements in cases with complex object lifetime requirements that would otherwise not be trivially possible.
Error Handling. Insertion beyond the capacity result in throwing std::bad_alloc() if exceptions are enabled or calling throw_bad_alloc() if not enabled.
std::out_of_range is thrown if out of bounds access is performed in at()
if exceptions are enabled, throw_out_of_range() if not enabled.
typename T
The type of element that will be stored.
Capacity
The maximum number of elements static_vector
can store, fixed at compile time.
typename Options
A type produced from
. boost::container::static_vector_options
static_vector
public
construct/copy/destruct() ;Constructs an empty
static_vector
. Throws. Nothing.
Complexity. Constant O(1).
( count);Constructs a
static_vector
containing count value initialized values.
Throws. If T's value initialization throws.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
( count, default_init_t);Constructs a
static_vector
containing count default initialized values.
Throws. If T's default initialization throws.
Complexity. Linear O(N).
Note. Non-standard extension
Parameters: |
|
||
Requires: |
|
( count, value);Constructs a
static_vector
containing count copies of value.
Throws. If T's copy constructor throws.
Complexity. Linear O(N).
Parameters: |
|
||||
Requires: |
|
template<typename Iterator> ( first, last);Constructs a
static_vector
containing copy of a range [first, last)
.
Throws. If T's constructor taking a dereferenced Iterator throws.
Complexity. Linear O(N).
Parameters: |
|
||||
Requires: |
|
( il);Constructs a
static_vector
containing copy of a range [il.begin(), il.end())
.
Throws. If T's constructor taking a dereferenced std::initializer_list throws.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
(static_vector other);Constructs a copy of other
static_vector
.
Throws. If T's copy constructor throws.
Complexity. Linear O(N).
Parameters: |
|
(static_vector other, );
(static_vector && other, ) ;
();
template< C, typename O> (static_vector< other);Constructs a copy of other
static_vector
.
Throws. If T's copy constructor throws.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
(static_vector && other) ;Move constructor. Moves Values stored in the other
static_vector
to this one.
Throws.
If has_nothrow_move<T>::value
is true
and T's move constructor throws.
If has_nothrow_move<T>::value
is false
and T's copy constructor throws.
Complexity. Linear O(N).
Parameters: |
|
template< C, typename O> (static_vector< other);Move constructor. Moves Values stored in the other
static_vector
to this one.
Throws.
If has_nothrow_move<T>::value
is true
and T's move constructor throws.
If has_nothrow_move<T>::value
is false
and T's copy constructor throws.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
static_vector & (static_vector & other);Copy assigns Values stored in the other
static_vector
to this one.
Throws. If T's copy constructor or copy assignment throws.
Complexity. Linear O(N).
Parameters: |
|
static_vector & ( il);Copy assigns Values stored in std::initializer_list to *this.
Throws. If T's copy constructor or copy assignment throws.
Complexity. Linear O(N).
Parameters: |
|
template< C, typename O> static_vector & (static_vector< other);Copy assigns Values stored in the other
static_vector
to this one.
Throws. If T's copy constructor or copy assignment throws.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
static_vector & (static_vector && other) ;Move assignment. Moves Values stored in the other
static_vector
to this one.
Throws.
If has_nothrow_move<T>::value
is true
and T's move constructor or move assignment throws.
If has_nothrow_move<T>::value
is false
and T's copy constructor or copy assignment throws.
Complexity. Linear O(N).
Parameters: |
|
template< C, typename O> static_vector & (static_vector< other);Move assignment. Moves Values stored in the other
static_vector
to this one.
Throws.
If has_nothrow_move<T>::value
is true
and T's move constructor or move assignment throws.
If has_nothrow_move<T>::value
is false
and T's copy constructor or copy assignment throws.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
~();Destructor. Destroys Values stored in this container.
Throws. Nothing
Complexity. Linear O(N).
static_vector
public member functions(static_vector & other);Swaps contents of the other
static_vector
and this one.
Throws.
If has_nothrow_move<T>::value
is true
and T's move constructor or move assignment throws,
If has_nothrow_move<T>::value
is false
and T's copy constructor or copy assignment throws,
Complexity. Linear O(N).
Parameters: |
|
template< C, typename O> (static_vector< other);Swaps contents of the other
static_vector
and this one.
Throws.
If has_nothrow_move<T>::value
is true
and T's move constructor or move assignment throws,
If has_nothrow_move<T>::value
is false
and T's copy constructor or copy assignment throws,
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
( count);Inserts or erases elements at the end such that the size becomes count. New elements are value initialized.
Throws. If T's value initialization throws.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
( count, default_init_t);Inserts or erases elements at the end such that the size becomes count. New elements are default initialized.
Throws. If T's default initialization throws.
Complexity. Linear O(N).
Note. Non-standard extension
Parameters: |
|
||
Requires: |
|
( count, value);Inserts or erases elements at the end such that the size becomes count. New elements are copy constructed from value.
Throws. If T's copy constructor throws.
Complexity. Linear O(N).
Parameters: |
|
||||
Requires: |
|
( count) ;This call has no effect because the Capacity of this container is constant.
Throws. Nothing.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
( value);Adds a copy of value at the end.
Throws. If T's copy constructor throws.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
( value);Moves value to the end.
Throws. If T's move constructor throws.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
();Destroys last value and decreases the size.
Throws. Nothing by default.
Complexity. Constant O(1).
Requires: |
|
( p, value);Inserts a copy of element at p.
Throws.
If T's copy constructor or copy assignment throws
If T's move constructor or move assignment throws.
Complexity. Constant or linear.
Parameters: |
|
||||
Requires: |
|
( p, value);Inserts a move-constructed element at p.
Throws. If T's move constructor or move assignment throws.
Complexity. Constant or linear.
Parameters: |
|
||||
Requires: |
|
( p, count, value);Inserts a count copies of value at p.
Throws.
If T's copy constructor or copy assignment throws.
If T's move constructor or move assignment throws.
Complexity. Linear O(N).
Parameters: |
|
||||||
Requires: |
|
template<typename Iterator> ( p, first, last);Inserts a copy of a range
[first, last)
at p.
Throws.
If T's constructor and assignment taking a dereferenced Iterator
.
If T's move constructor or move assignment throws.
Complexity. Linear O(N).
Parameters: |
|
||||||
Requires: |
|
( p, il);Inserts a copy of a range
[il.begin(), il.end())
at p.
Throws.
If T's constructor and assignment taking a dereferenced std::initializer_list iterator.
Complexity. Linear O(N).
Parameters: |
|
||||
Requires: |
|
( p);Erases T from p.
Throws. If T's move assignment throws.
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
( first, last);Erases Values from a range
[first, last)
.
Throws. If T's move assignment throws.
Complexity. Linear O(N).
Parameters: |
|
||||
Requires: |
|
template<typename Iterator> ( first, last);Assigns a range
[first, last)
of Values to this container.
Throws. If T's copy constructor or copy assignment throws,
Complexity. Linear O(N).
Parameters: |
|
||||
Requires: |
|
( il);Assigns a range
[il.begin(), il.end())
of Values to this container.
Throws. If T's copy constructor or copy assignment throws,
Complexity. Linear O(N).
Parameters: |
|
||
Requires: |
|
( count, value);Assigns a count copies of value to this container.
Throws. If T's copy constructor or copy assignment throws.
Complexity. Linear O(N).
Parameters: |
|
||||
Requires: |
|
template< Args> ( args);Inserts a T constructed with
std::forward<Args>(args)
... in the end of the container.
Throws. If in-place constructor throws or T's move constructor throws.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
A reference to the created object. |
template< Args> ( p, args);Inserts a T constructed with
std::forward<Args>(args)
... before p.
Throws. If in-place constructor throws or if T's move constructor or move assignment throws.
Complexity. Constant or linear.
Parameters: |
|
||||
Requires: |
|
() ;Removes all elements from the container.
Throws. Nothing.
Complexity. Constant O(1).
( i);Returns reference to the i-th element.
Throws. std::out_of_range
exception by default.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
reference to the i-th element from the beginning of the container. |
( i) ;Returns const reference to the i-th element.
Throws. std::out_of_range
exception by default.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
const reference to the i-th element from the beginning of the container. |
( i);Returns reference to the i-th element.
Throws. Nothing by default.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
reference to the i-th element from the beginning of the container. |
( i) ;Returns const reference to the i-th element.
Throws. Nothing by default.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
const reference to the i-th element from the beginning of the container. |
( i);Returns a iterator to the i-th element.
Throws. Nothing by default.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
a iterator to the i-th element. |
( i) ;Returns a const_iterator to the i-th element.
Throws. Nothing by default.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
a const_iterator to the i-th element. |
( p);Returns the index of the element pointed by p.
Throws. Nothing by default.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
The index of the element pointed by p. |
( p) ;Returns the index of the element pointed by p.
Throws. Nothing by default.
Complexity. Constant O(1).
Parameters: |
|
||
Requires: |
|
||
Returns: |
a const_iterator to the i-th element. |
();Returns reference to the first element.
Throws. Nothing by default.
Complexity. Constant O(1).
Requires: |
|
Returns: |
reference to the first element from the beginning of the container. |
() ;Returns const reference to the first element.
Throws. Nothing by default.
Complexity. Constant O(1).
Requires: |
|
Returns: |
const reference to the first element from the beginning of the container. |
();Returns reference to the last element.
Throws. Nothing by default.
Complexity. Constant O(1).
Requires: |
|
Returns: |
reference to the last element from the beginning of the container. |
() ;Returns const reference to the first element.
Throws. Nothing by default.
Complexity. Constant O(1).
Requires: |
|
Returns: |
const reference to the last element from the beginning of the container. |
() ;Pointer such that
[data(), data() + size())
is a valid range. For a non-empty vector data() == &front()
. Throws. Nothing.
Complexity. Constant O(1).
() ;Const pointer such that
[data(), data() + size())
is a valid range. For a non-empty vector data() == &front()
. Throws. Nothing.
Complexity. Constant O(1).
() ;Returns iterator to the first element.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
iterator to the first element contained in the vector. |
() ;Returns const iterator to the first element.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
const_iterator to the first element contained in the vector. |
() ;Returns const iterator to the first element.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
const_iterator to the first element contained in the vector. |
() ;Returns iterator to the one after the last element.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
iterator pointing to the one after the last element contained in the vector. |
() ;Returns const iterator to the one after the last element.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
const_iterator pointing to the one after the last element contained in the vector. |
() ;Returns const iterator to the one after the last element.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
const_iterator pointing to the one after the last element contained in the vector. |
() ;Returns reverse iterator to the first element of the reversed container.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
reverse_iterator pointing to the beginning of the reversed static_vector. |
() ;Returns const reverse iterator to the first element of the reversed container.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
const_reverse_iterator pointing to the beginning of the reversed static_vector. |
() ;Returns const reverse iterator to the first element of the reversed container.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
const_reverse_iterator pointing to the beginning of the reversed static_vector. |
() ;Returns reverse iterator to the one after the last element of the reversed container.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
reverse_iterator pointing to the one after the last element of the reversed static_vector. |
() ;Returns const reverse iterator to the one after the last element of the reversed container.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
const_reverse_iterator pointing to the one after the last element of the reversed static_vector. |
() ;Returns const reverse iterator to the one after the last element of the reversed container.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
const_reverse_iterator pointing to the one after the last element of the reversed static_vector. |
() ;Returns the number of stored elements.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
Number of elements contained in the container. |
() ;Queries if the container contains elements.
Throws. Nothing.
Complexity. Constant O(1).
Returns: |
true if the number of elements contained in the container is equal to 0. |