piranha
0.10
|
Static vector class. More...
#include <piranha/static_vector.hpp>
Public Types | |
using | size_type = typename detail::static_vector_size_type< MaxSize >::type |
Size type. More... | |
typedef T | value_type |
Contained type. | |
typedef value_type * | iterator |
Iterator type. | |
typedef value_type const * | const_iterator |
Const iterator type. | |
Public Member Functions | |
static_vector () | |
Default constructor. More... | |
static_vector (const static_vector &other) | |
Copy constructor. More... | |
static_vector (static_vector &&other) noexcept | |
Move constructor. More... | |
static_vector (const size_type &n, const value_type &x) | |
Constructor from multiple copies. More... | |
~static_vector () | |
Destructor. More... | |
static_vector & | operator= (const static_vector &other) |
Copy assignment operator. More... | |
static_vector & | operator= (static_vector &&other) noexcept |
Move assignment operator. More... | |
const value_type & | operator[] (const size_type &n) const |
Const subscript operator. More... | |
value_type & | operator[] (const size_type &n) |
Subscript operator. More... | |
iterator | begin () |
Begin iterator. More... | |
iterator | end () |
End iterator. More... | |
const_iterator | begin () const |
Const begin iterator. More... | |
const_iterator | end () const |
Const end iterator. More... | |
bool | operator== (const static_vector &other) const |
Equality operator. More... | |
bool | operator!= (const static_vector &other) const |
Inequality operator. More... | |
void | push_back (const value_type &x) |
Copy-add element at the end of the vector. More... | |
void | push_back (value_type &&x) |
Move-add element at the end of the vector. More... | |
template<typename... Args, emplace_enabler< Args... > = 0> | |
void | emplace_back (Args &&... params) |
Construct in-place at the end of the vector. More... | |
size_type | size () const |
Size. More... | |
bool | empty () const |
Empty test. More... | |
void | resize (const size_type &new_size) |
Resize. More... | |
iterator | erase (const_iterator it) |
Erase element. More... | |
void | clear () |
Clear. More... | |
template<typename U = T, hash_enabler< U > = 0> | |
std::size_t | hash () const |
Hash value. More... | |
Static Public Attributes | |
static const size_type | max_size = MaxSize |
Maximum size. More... | |
Friends | |
template<typename U = T, ostream_enabler< U > = 0> | |
std::ostream & | operator<< (std::ostream &os, const static_vector &v) |
Stream operator overload for piranha::static_vector. More... | |
Static vector class.
This class represents a dynamic array that avoids runtime memory allocation. Memory storage is provided by a contiguous memory block stored within the class. The size of the internal storage is enough to fit at least MaxSize
objects.
The interface of this class mimics part of the interface of std::vector
.
T
must satisfy piranha::is_container_element.MaxSize
must be non-null.Unless otherwise specified, this class provides the strong exception safety guarantee for all operations.
After a move operation, the container will be left in a state equivalent to a default-constructed instance.
Definition at line 99 of file static_vector.hpp.
using piranha::static_vector< T, MaxSize >::size_type = typename detail::static_vector_size_type<MaxSize>::type |
Size type.
An unsigned integer type large enough to represent MaxSize
.
Definition at line 112 of file static_vector.hpp.
|
inline |
Default constructor.
Will construct a vector of size 0.
Definition at line 187 of file static_vector.hpp.
|
inline |
Copy constructor.
other | target of the copy operation. |
unspecified | any exception thrown by the copy constructor of T . |
Definition at line 196 of file static_vector.hpp.
|
inlinenoexcept |
Move constructor.
other | target of the move operation. |
Definition at line 226 of file static_vector.hpp.
|
inlineexplicit |
Constructor from multiple copies.
Will construct a vector containing n
copies of x
.
n | number of copies of x that will be inserted in the vector. |
x | element whose copies will be inserted in the vector. |
unspecified | any exception thrown by push_back(). |
Definition at line 252 of file static_vector.hpp.
|
inline |
Destructor.
Will destroy all elements of the vector.
Definition at line 267 of file static_vector.hpp.
|
inline |
Begin iterator.
Definition at line 368 of file static_vector.hpp.
|
inline |
Const begin iterator.
Definition at line 384 of file static_vector.hpp.
|
inline |
Clear.
This method will destroy all elements of the vector and set the size to zero.
Definition at line 588 of file static_vector.hpp.
|
inline |
Construct in-place at the end of the vector.
value_type
is constructible from the variadic arguments pack.Input parameters will be used to construct an instance of T
at the end of the container.
params | arguments that will be used to construct the new element. |
std::bad_alloc | if the insertion of the new element would lead to a size greater than MaxSize . |
unspecified | any exception thrown by the constructor of T from the input parameters. |
Definition at line 473 of file static_vector.hpp.
|
inline |
Empty test.
true
if the size of the container is zero, false
otherwise. Definition at line 493 of file static_vector.hpp.
|
inline |
End iterator.
Definition at line 376 of file static_vector.hpp.
|
inline |
Const end iterator.
Definition at line 392 of file static_vector.hpp.
|
inline |
Erase element.
This method will erase the element to which it
points. The return value will be the iterator following the erased element (which will be the end iterator if it
points to the last element of the vector).
it
must be a valid iterator to an element in this
.
it | iterator to the element of this to be removed. |
Definition at line 558 of file static_vector.hpp.
|
inline |
Hash value.
T
satisfies piranha::is_hashable.unspecified | any exception resulting from calculating the hash value(s) of the individual elements. |
Definition at line 617 of file static_vector.hpp.
|
inline |
Inequality operator.
other | argument for the comparison. |
unspecified | any exception thrown by operator==(). |
Definition at line 417 of file static_vector.hpp.
|
inline |
Copy assignment operator.
other | target of the copy assignment operation. |
this
.unspecified | any exception thrown by the copy constructor of T . |
Definition at line 283 of file static_vector.hpp.
|
inlinenoexcept |
Move assignment operator.
other | target of the move assignment operation. |
this
. Definition at line 307 of file static_vector.hpp.
|
inline |
Equality operator.
other | argument for the comparison. |
true
if the sizes of the vectors are the same and all elements of this
compare as equal to the elements in other
, false
otherwise.unspecified | any exception thrown by the comparison operator of the value type. |
Definition at line 405 of file static_vector.hpp.
|
inline |
Const subscript operator.
n | index of the desired element. |
n
; Definition at line 350 of file static_vector.hpp.
|
inline |
Subscript operator.
n | index of the desired element. |
n
; Definition at line 360 of file static_vector.hpp.
|
inline |
Copy-add element at the end of the vector.
x
is copy-inserted at the end of the container.
x | element to be inserted. |
std::bad_alloc | if the insertion of x would lead to a size greater than MaxSize . |
unspecified | any exception thrown by the copy constructor of T . |
Definition at line 430 of file static_vector.hpp.
|
inline |
Move-add element at the end of the vector.
x
is move-inserted at the end of the container.
x | element to be inserted. |
std::bad_alloc | if the insertion of x would lead to a size greater than MaxSize . |
Definition at line 446 of file static_vector.hpp.
|
inline |
Resize.
After this operation, the number of elements stored in the container will be new_size
. If new_size
is greater than the size of the object before the operation, the new elements will be value-initialized and placed at the end of the container. If new_size
is smaller than the size of the object before the operation, the first new_size
object in the vector will be preserved.
new_size | new size for the vector. |
std::bad_alloc | if new_size is greater than MaxSize . |
unspecified | any exception thrown by the default constructor of T . |
Definition at line 509 of file static_vector.hpp.
|
inline |
Size.
this
. Definition at line 485 of file static_vector.hpp.
|
friend |
Stream operator overload for piranha::static_vector.
U
satisfies piranha::is_ostreamable.Will print to stream a human-readable representation of v
.
os | target stream. |
v | vector to be streamed. |
os
.unspecified | any exception thrown by printing to stream instances of the value type of v . |
Definition at line 642 of file static_vector.hpp.
|
static |