rosidl_runtime_cpp
master
Generate the rosidl interfaces in C++.
|
A container based on std::vector but with an upper bound. More...
#include <bounded_vector.hpp>
Public Member Functions | |
BoundedVector () noexcept(std::is_nothrow_default_constructible< Alloc >::value) | |
Create a BoundedVector with no elements. More... | |
BoundedVector (const typename Base::allocator_type &a) noexcept | |
Creates a BoundedVector with no elements. More... | |
BoundedVector (typename Base::size_type n, const typename Base::allocator_type &a=allocator_type()) | |
Create a BoundedVector with default constructed elements. More... | |
BoundedVector (typename Base::size_type n, const typename Base::value_type &value, const typename Base::allocator_type &a=allocator_type()) | |
Create a BoundedVector with copies of an exemplar element. More... | |
BoundedVector (const BoundedVector &x) | |
BoundedVector copy constructor. More... | |
BoundedVector (BoundedVector &&x) noexcept | |
BoundedVector move constructor. More... | |
BoundedVector (const BoundedVector &x, const typename Base::allocator_type &a) | |
Copy constructor with alternative allocator. More... | |
BoundedVector (std::initializer_list< typename Base::value_type > l, const typename Base::allocator_type &a=typename Base::allocator_type()) | |
Build a BoundedVector from an initializer list. More... | |
template<typename InputIterator > | |
BoundedVector (InputIterator first, InputIterator last, const typename Base::allocator_type &a=allocator_type()) | |
Build a BoundedVector from a range. More... | |
~BoundedVector () noexcept | |
The dtor only erases the elements. More... | |
BoundedVector & | operator= (const BoundedVector &x) |
BoundedVector assignment operator. More... | |
BoundedVector & | operator= (BoundedVector &&x) |
BoundedVector move assignment operator More... | |
BoundedVector & | operator= (std::initializer_list< typename Base::value_type > l) |
BoundedVector list assignment operator. More... | |
void | assign (typename Base::size_type n, const typename Base::value_type &val) |
Assign a given value to a BoundedVector. More... | |
template<typename InputIterator > | |
void | assign (InputIterator first, InputIterator last) |
Assign a range to a BoundedVector. More... | |
void | assign (std::initializer_list< typename Base::value_type > l) |
Assign an initializer list to a BoundedVector. More... | |
Base::size_type | max_size () const noexcept |
void | resize (typename Base::size_type new_size) |
Resize the BoundedVector to the specified number of elements. More... | |
void | resize (typename Base::size_type new_size, const typename Base::value_type &x) |
Resize the BoundedVector to the specified number of elements. More... | |
void | reserve (typename Base::size_type n) |
Attempt to preallocate enough memory for specified number of elements. More... | |
template<typename T , typename std::enable_if< !std::is_same< T, Tp >::value &&!std::is_same< T, bool >::value >::type * = nullptr> | |
T * | data () noexcept |
Return a pointer such that [data(), data() + size()) is a valid range. More... | |
template<typename T , typename std::enable_if< !std::is_same< T, Tp >::value &&!std::is_same< T, bool >::value >::type * = nullptr> | |
const T * | data () const noexcept |
void | push_back (const typename Base::value_type &x) |
Add data to the end of the BoundedVector. More... | |
void | push_back (typename Base::value_type &&x) |
template<typename ... Args> | |
auto | emplace_back (Args &&... args) |
Add data to the end of the BoundedVector. More... | |
template<typename ... Args> | |
Base::iterator | emplace (typename Base::const_iterator position, Args &&... args) |
Insert an object in BoundedVector before specified iterator. More... | |
Base::iterator | insert (typename Base::const_iterator position, const typename Base::value_type &x) |
Insert given value into BoundedVector before specified iterator. More... | |
Base::iterator | insert (typename Base::const_iterator position, typename Base::value_type &&x) |
Insert given rvalue into BoundedVector before specified iterator. More... | |
Base::iterator | insert (typename Base::const_iterator position, std::initializer_list< typename Base::value_type > l) |
Insert an initializer_list into the BoundedVector. More... | |
Base::iterator | insert (typename Base::const_iterator position, typename Base::size_type n, const typename Base::value_type &x) |
Insert a number of copies of given data into the BoundedVector. More... | |
template<typename InputIterator > | |
Base::iterator | insert (typename Base::const_iterator position, InputIterator first, InputIterator last) |
Insert a range into the BoundedVector. More... | |
T | begin (T... args) |
T | end (T... args) |
T | rbegin (T... args) |
T | rend (T... args) |
T | cbegin (T... args) |
T | cend (T... args) |
T | crbegin (T... args) |
T | crend (T... args) |
T | size (T... args) |
T | shrink_to_fit (T... args) |
T | capacity (T... args) |
T | empty (T... args) |
T | at (T... args) |
T | front (T... args) |
T | back (T... args) |
T | erase (T... args) |
T | pop_back (T... args) |
T | clear (T... args) |
Friends | |
bool | operator== (const BoundedVector &x, const BoundedVector &y) |
Vector equality comparison. More... | |
bool | operator< (const BoundedVector &x, const BoundedVector &y) |
Vector ordering relation. More... | |
bool | operator!= (const BoundedVector &x, const BoundedVector &y) |
Based on operator==. More... | |
bool | operator> (const BoundedVector &x, const BoundedVector &y) |
Based on operator<. More... | |
bool | operator<= (const BoundedVector &x, const BoundedVector &y) |
Based on operator<. More... | |
bool | operator>= (const BoundedVector &x, const BoundedVector &y) |
Based on operator<. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from std::vector< Tp, std::allocator< Tp > > | |
T | push_back (T... args) |
T | crbegin (T... args) |
T | erase (T... args) |
T | data (T... args) |
T | insert (T... args) |
T | pop_back (T... args) |
T | shrink_to_fit (T... args) |
T | back (T... args) |
T | end (T... args) |
T | resize (T... args) |
T | emplace_back (T... args) |
T | size (T... args) |
T | cbegin (T... args) |
T | front (T... args) |
T | ~vector (T... args) |
T | rbegin (T... args) |
T | crend (T... args) |
T | assign (T... args) |
T | operator= (T... args) |
T | vector (T... args) |
T | reserve (T... args) |
T | capacity (T... args) |
T | empty (T... args) |
T | cend (T... args) |
T | swap (T... args) |
T | max_size (T... args) |
T | rend (T... args) |
T | get_allocator (T... args) |
T | clear (T... args) |
T | at (T... args) |
T | emplace (T... args) |
T | operator[] (T... args) |
T | begin (T... args) |
A container based on std::vector but with an upper bound.
Meets the same requirements as std::vector.
Tp | Type of element |
UpperBound | The upper bound for the number of elements |
Alloc | Allocator type, defaults to std::allocator<Tp> |
|
inlinenoexcept |
Create a BoundedVector with no elements.
|
inlineexplicitnoexcept |
Creates a BoundedVector with no elements.
a | An allocator object |
|
inlineexplicit |
Create a BoundedVector with default constructed elements.
This constructor fills the BoundedVector with n default constructed elements.
n | The number of elements to initially create |
a | An allocator |
|
inline |
Create a BoundedVector with copies of an exemplar element.
This constructor fills the BoundedVector with n copies of value.
n | The number of elements to initially create |
value | An element to copy |
a | An allocator |
|
inline |
BoundedVector copy constructor.
The newly-created BoundedVector uses a copy of the allocation object used by x. All the elements of x are copied, but any extra memory in x (for fast expansion) will not be copied.
x | A BoundedVector of identical element and allocator types |
|
inlinenoexcept |
BoundedVector move constructor.
The newly-created BoundedVector contains the exact contents of x. The contents of x are a valid, but unspecified BoundedVector.
x | A BoundedVector of identical element and allocator types |
|
inline |
Copy constructor with alternative allocator.
|
inline |
Build a BoundedVector from an initializer list.
Create a BoundedVector consisting of copies of the elements in the initializer_list l.
This will call the element type's copy constructor N times (where N is l.size()) and do no memory reallocation.
l | An initializer_list |
a | An allocator |
|
inline |
Build a BoundedVector from a range.
Create a BoundedVector consisting of copies of the elements from [first,last).
If the iterators are forward, bidirectional, or random-access, then this will call the elements' copy constructor N times (where N is distance(first,last)) and do no memory reallocation. But if only input iterators are used, then this will do at most 2N calls to the copy constructor, and logN memory reallocations.
first | An input iterator |
last | An input iterator |
a | An allocator |
|
inlinenoexcept |
The dtor only erases the elements.
Note that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.
|
inline |
BoundedVector assignment operator.
All the elements of x are copied, but any extra memory in x (for fast expansion) will not be copied. Unlike the copy constructor, the allocator object is not copied.
x | A BoundedVector of identical element and allocator types |
|
inline |
BoundedVector move assignment operator
x | A BoundedVector of identical element and allocator types. |
|
inline |
BoundedVector list assignment operator.
This function fills a BoundedVector with copies of the elements in the initializer list l.
Note that the assignment completely changes the BoundedVector and that the resulting BoundedVector's size is the same as the number of elements assigned. Old data may be lost.
l | An initializer_list |
|
inline |
Assign a given value to a BoundedVector.
This function fills a BoundedVector with n copies of the given value. Note that the assignment completely changes the BoundedVector and that the resulting BoundedVector's size is the same as the number of elements assigned. Old data may be lost.
n | Number of elements to be assigned |
val | Value to be assigned |
|
inline |
Assign a range to a BoundedVector.
This function fills a BoundedVector with copies of the elements in the range [first,last).
Note that the assignment completely changes the BoundedVector and that the resulting BoundedVector's size is the same as the number of elements assigned. Old data may be lost.
first | An input iterator |
last | An input iterator |
|
inline |
Assign an initializer list to a BoundedVector.
This function fills a BoundedVector with copies of the elements in the initializer list l.
Note that the assignment completely changes the BoundedVector and that the resulting BoundedVector's size is the same as the number of elements assigned. Old data may be lost.
l | An initializer_list |
|
inlinenoexcept |
Returns the size() of the largest possible BoundedVector.
|
inline |
Resize the BoundedVector to the specified number of elements.
This function will resize the BoundedVector to the specified number of elements. If the number is smaller than the BoundedVector's current size the BoundedVector is truncated, otherwise default constructed elements are appended.
new_size | Number of elements the BoundedVector should contain |
|
inline |
Resize the BoundedVector to the specified number of elements.
This function will resize the BoundedVector to the specified number of elements. If the number is smaller than the BoundedVector's current size the BoundedVector is truncated, otherwise the BoundedVector is extended and new elements are populated with given data.
new_size | Number of elements the BoundedVector should contain |
x | Data with which new elements should be populated |
|
inline |
Attempt to preallocate enough memory for specified number of elements.
This function attempts to reserve enough memory for the BoundedVector to hold the specified number of elements. If the number requested is more than max_size(), length_error is thrown.
The advantage of this function is that if optimal code is a necessity and the user can determine the number of elements that will be required, the user can reserve the memory in advance, and thus prevent a possible reallocation of memory and copying of BoundedVector data.
n | Number of elements required |
std::length_error | If n exceeds max_size() |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Add data to the end of the BoundedVector.
This is a typical stack operation. The function creates an element at the end of the BoundedVector and assigns the given data to it. Due to the nature of a BoundedVector this operation can be done in constant time if the BoundedVector has preallocated space available.
x | Data to be added |
|
inline |
|
inline |
Add data to the end of the BoundedVector.
This is a typical stack operation. The function creates an element at the end of the BoundedVector and assigns the given data to it. Due to the nature of a BoundedVector this operation can be done in constant time if the BoundedVector has preallocated space available.
args | Arguments to be forwarded to the constructor of Tp |
|
inline |
Insert an object in BoundedVector before specified iterator.
This function will insert an object of type T constructed with T(std::forward<Args>(args)...) before the specified location. Note that this kind of operation could be expensive for a BoundedVector and if it is frequently used the user should consider using std::list.
position | A const_iterator into the BoundedVector |
args | Arguments |
|
inline |
Insert given value into BoundedVector before specified iterator.
This function will insert a copy of the given value before the specified location. Note that this kind of operation could be expensive for a BoundedVector and if it is frequently used the user should consider using std::list.
position | A const_iterator into the BoundedVector |
x | Data to be inserted |
|
inline |
Insert given rvalue into BoundedVector before specified iterator.
This function will insert a copy of the given rvalue before the specified location. Note that this kind of operation could be expensive for a BoundedVector and if it is frequently used the user should consider using std::list.
position | A const_iterator into the BoundedVector |
x | Data to be inserted |
|
inline |
Insert an initializer_list into the BoundedVector.
This function will insert copies of the data in the initializer_list l into the BoundedVector before the location specified by position.
Note that this kind of operation could be expensive for a BoundedVector and if it is frequently used the user should consider using std::list.
position | An iterator into the BoundedVector |
l | An initializer_list |
|
inline |
Insert a number of copies of given data into the BoundedVector.
This function will insert a specified number of copies of the given data before the location specified by position.
Note that this kind of operation could be expensive for a BoundedVector and if it is frequently used the user should consider using std::list.
position | A const_iterator into the BoundedVector |
n | Number of elements to be inserted |
x | Data to be inserted |
|
inline |
Insert a range into the BoundedVector.
This function will insert copies of the data in the range [first,last) into the BoundedVector before the location specified by pos.
Note that this kind of operation could be expensive for a BoundedVector and if it is frequently used the user should consider using std::list.
position | A const_iterator into the BoundedVector |
first | An input iterator |
last | An input iterator |
T std::vector::begin |
T std::vector::end |
T std::vector::rbegin |
T std::vector::rend |
T std::vector::cbegin |
T std::vector::cend |
T std::vector::crbegin |
T std::vector::crend |
T std::vector::size |
T std::vector::shrink_to_fit |
T std::vector::capacity |
T std::vector::empty |
T std::vector::at |
T std::vector::front |
T std::vector::back |
T std::vector::erase |
T std::vector::pop_back |
T std::vector::clear |
|
friend |
Vector equality comparison.
This is an equivalence relation. It is linear in the size of the vectors. Vectors are considered equivalent if their sizes are equal, and if corresponding elements compare equal.
x | A BoundedVector |
y | A BoundedVector of the same type as x |
|
friend |
Vector ordering relation.
This is a total ordering relation. It is linear in the size of the vectors. The elements must be comparable with <
.
See std::lexicographical_compare() for how the determination is made.
x | A BoundedVector |
y | A BoundedVector of the same type as x |
|
friend |
Based on operator==.
|
friend |
Based on operator<.
|
friend |
Based on operator<.
|
friend |
Based on operator<.