|
| small_vector ()=default |
| Default constructor. More...
|
|
| small_vector (const small_vector &other)=default |
| Copy constructor. More...
|
|
| small_vector (small_vector &&other)=default |
| Move constructor. More...
|
|
template<typename U , init_list_enabler< U > = 0> |
| small_vector (std::initializer_list< U > l) |
| Constructor from initializer list. More...
|
|
| small_vector (const size_type &size, const T &value) |
| Constructor from size and value. More...
|
|
| ~small_vector ()=default |
| Destructor.
|
|
small_vector & | operator= (const small_vector &)=default |
| Copy assignment operator. More...
|
|
small_vector & | operator= (small_vector &&)=default |
| 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...
|
|
void | push_back (const value_type &x) |
| Copy-add element at the end. More...
|
|
void | push_back (value_type &&x) |
| Move-add element at the end. More...
|
|
iterator | begin () |
| Mutable begin iterator. More...
|
|
iterator | end () |
| Mutable end iterator. More...
|
|
const_iterator | begin () const |
| Const begin iterator. More...
|
|
const_iterator | end () const |
| Const end iterator. More...
|
|
size_type | size () const |
| Size. More...
|
|
bool | is_static () const |
| Static storage flag. More...
|
|
template<typename U = value_type, equality_enabler< U > = 0> |
bool | operator== (const small_vector &other) const |
| Equality operator. More...
|
|
template<typename U = value_type, equality_enabler< U > = 0> |
bool | operator!= (const small_vector &other) const |
| Inequality operator. More...
|
|
template<typename U = value_type, hash_enabler< U > = 0> |
std::size_t | hash () const |
| Hash method. More...
|
|
bool | empty () const |
| Empty test. More...
|
|
void | resize (const size_type &size) |
| Resize. More...
|
|
template<typename U = value_type, add_enabler< U > = 0> |
void | add (small_vector &retval, const small_vector &other) const |
| Vector addition. More...
|
|
template<typename U = value_type, sub_enabler< U > = 0> |
void | sub (small_vector &retval, const small_vector &other) const |
| Vector subtraction. More...
|
|
iterator | erase (const_iterator it) |
| Erase element. More...
|
|
std::tuple< size_type, iterator, iterator > | size_begin_end () |
| Size, begin and end. More...
|
|
std::tuple< size_type, const_iterator, const_iterator > | size_begin_end () const |
| Size, begin and end (const version). More...
|
|
template<typename T, typename S = std::integral_constant<std::size_t, 0u>>
class piranha::small_vector< T, S >
Small vector class.
This class is a sequence container similar to the standard std::vector
class. The class will avoid dynamic memory allocation by using internal static storage up to a certain number of stored elements. If S
is a zero integral constant, this number is calculated automatically (but it will always be at least 1). Otherwise, the limit number is set to S::value
.
Type requirements
Exception safety guarantee
Unless otherwise specified, this class provides the strong exception safety guarantee for all operations.
Move semantics
After a move operation, the container will be empty.
Definition at line 45 of file small_vector_fwd.hpp.
template<typename T , typename S = std::integral_constant<std::size_t, 0u>>
template<typename U , init_list_enabler< U > = 0>
Constructor from initializer list.
- Note
- This constructor is enabled only if
U
is safely convertible to T
.
The elements of l
will be added to a default-constructed object, after conversion to T
via piranha::safe_cast().
- Parameters
-
l | list that will be used for initialisation. |
- Exceptions
-
Definition at line 676 of file small_vector.hpp.
template<typename T , typename S = std::integral_constant<std::size_t, 0u>>
template<typename U = value_type, add_enabler< U > = 0>
Vector addition.
- Note
- This method is enabled only if
value_type
satisfies piranha::has_add3.
Will compute the element-wise addition of this
and other
via piranha::math::add3(), storing the result in retval
. In face of exceptions during the addition of two elements, retval
will be left in an unspecified but valid state, provided that piranha::math::add3() offers the basic exception safety guarantee.
this
, retval
and/or other
are allowed to be the same object, provided that piranha::math::add3() also supports this type of usage.
- Parameters
-
retval | result of the addition. |
other | argument for the addition. |
- Exceptions
-
std::invalid_argument | if the sizes of this and other do not coincide. |
unspecified | any exception thrown by:
|
Definition at line 967 of file small_vector.hpp.
template<typename T , typename S = std::integral_constant<std::size_t, 0u>>
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
.
- Parameters
-
it | iterator to the element of this to be removed. |
- Returns
- the iterator following the erased element.
Definition at line 1027 of file small_vector.hpp.
template<typename T , typename S = std::integral_constant<std::size_t, 0u>>
Copy-add element at the end.
NOTE: if x
is an element of the vector, the behaviour will be undefined.
- Parameters
-
x | object that will be added at the end of the vector. |
- Exceptions
-
std::bad_alloc | in case of memory allocation errors or if the size limit is exceeded. |
unspecified | any exception thrown by the copy constructor of T . |
Definition at line 741 of file small_vector.hpp.
template<typename T , typename S = std::integral_constant<std::size_t, 0u>>
Move-add element at the end.
NOTE: if x
is an element of the vector, the behaviour will be undefined.
- Parameters
-
x | object that will be added at the end of the vector. |
- Exceptions
-
std::bad_alloc | in case of memory allocation errors or if the size limit is exceeded. |
Definition at line 753 of file small_vector.hpp.
template<typename T , typename S = std::integral_constant<std::size_t, 0u>>
template<typename U = value_type, sub_enabler< U > = 0>
Vector subtraction.
- Note
- This method is enabled only if
value_type
satisfies piranha::has_sub3.
Will compute the element-wise subtraction of this
and other
via piranha::math::sub3(), storing the result in retval
. In face of exceptions during the subtraction of two elements, retval
will be left in an unspecified but valid state, provided that piranha::math::sub3() offers the basic exception safety guarantee.
this
, retval
and/or other
are allowed to be the same object, provided that piranha::math::sub3() also supports this type of usage.
- Parameters
-
retval | result of the subtraction. |
other | argument for the subtraction. |
- Exceptions
-
std::invalid_argument | if the sizes of this and other do not coincide. |
unspecified | any exception thrown by:
|
Definition at line 1003 of file small_vector.hpp.