rosidl_runtime_cpp
master
Generate the rosidl interfaces in C++.
|
Go to the documentation of this file.
15 #ifndef ROSIDL_RUNTIME_CPP__BOUNDED_VECTOR_HPP_
16 #define ROSIDL_RUNTIME_CPP__BOUNDED_VECTOR_HPP_
35 template<
typename Tp, std::
size_t UpperBound,
typename Alloc = std::allocator<Tp>>
42 using typename Base::value_type;
43 using typename Base::pointer;
44 using typename Base::const_pointer;
45 using typename Base::reference;
46 using typename Base::const_reference;
47 using typename Base::iterator;
48 using typename Base::const_iterator;
49 using typename Base::const_reverse_iterator;
50 using typename Base::reverse_iterator;
51 using typename Base::size_type;
52 using typename Base::difference_type;
53 using typename Base::allocator_type;
57 noexcept (
std::is_nothrow_default_constructible<Alloc>::value)
67 const typename Base::allocator_type & a)
82 typename Base::size_type n,
83 const typename Base::allocator_type & a = allocator_type())
100 typename Base::size_type n,
101 const typename Base::value_type & value,
102 const typename Base::allocator_type & a = allocator_type())
105 if (n > UpperBound) {
153 const typename Base::allocator_type & a =
typename Base::allocator_type())
156 if (l.
size() > UpperBound) {
177 typename InputIterator
182 const typename Base::allocator_type & a = allocator_type())
183 :
Base(first, last, a)
185 if (
size() > UpperBound) {
210 (void)Base::operator=(x);
240 if (l.
size() > UpperBound) {
261 typename Base::size_type n,
262 const typename Base::value_type & val)
264 if (n > UpperBound) {
284 typename InputIterator
287 assign(InputIterator first, InputIterator last)
290 do_assign(first, last, cat());
308 if (l.
size() > UpperBound) {
325 typename Base::size_type
342 resize(
typename Base::size_type new_size)
344 if (new_size > UpperBound) {
363 typename Base::size_type new_size,
364 const typename Base::value_type & x)
366 if (new_size > UpperBound) {
395 if (n > UpperBound) {
401 using Base::operator[];
450 if (
size() >= UpperBound) {
459 if (
size() >= UpperBound) {
476 template<
typename ... Args>
480 if (
size() >= UpperBound) {
498 template<
typename ... Args>
499 typename Base::iterator
501 typename Base::const_iterator position,
504 if (
size() >= UpperBound) {
507 return Base::emplace(position, std::forward<Args>(args) ...);
522 typename Base::iterator
524 typename Base::const_iterator position,
525 const typename Base::value_type & x)
527 if (
size() >= UpperBound) {
545 typename Base::iterator
547 typename Base::const_iterator position,
548 typename Base::value_type && x)
550 if (
size() >= UpperBound) {
569 typename Base::iterator
571 typename Base::const_iterator position,
574 if (
size() + l.
size() > UpperBound) {
594 typename Base::iterator
596 typename Base::const_iterator position,
597 typename Base::size_type n,
598 const typename Base::value_type & x)
600 if (
size() + n > UpperBound) {
622 typename InputIterator
624 typename Base::iterator
626 typename Base::const_iterator position,
631 return do_insert(position, first, last, cat());
641 typename InputIterator
665 typename InputIterator
667 typename Base::iterator
669 typename Base::const_iterator position,
674 const auto orig_size =
size();
675 const auto idx = position -
cbegin();
677 while (first != last) {
684 auto pos =
begin() + idx;
686 return begin() + idx;
692 typename Base::iterator
694 typename Base::const_iterator position,
700 if ((dist < 0) || (
size() +
static_cast<size_t>(dist) > UpperBound)) {
722 return static_cast<const Base &
>(x) ==
static_cast<const Base &
>(y);
742 return static_cast<const Base &
>(x) <
static_cast<const Base &
>(y);
751 return static_cast<const Base &
>(x) !=
static_cast<const Base &
>(y);
760 return static_cast<const Base &
>(x) >
static_cast<const Base &
>(y);
769 return static_cast<const Base &
>(x) <=
static_cast<const Base &
>(y);
778 return static_cast<const Base &
>(x) >=
static_cast<const Base &
>(y);
783 template<
typename Tp, std::
size_t UpperBound,
typename Alloc>
792 #endif // ROSIDL_RUNTIME_CPP__BOUNDED_VECTOR_HPP_
BoundedVector(const BoundedVector &x, const typename Base::allocator_type &a)
Copy constructor with alternative allocator.
Definition: bounded_vector.hpp:136
~BoundedVector() noexcept
The dtor only erases the elements.
Definition: bounded_vector.hpp:196
void resize(typename Base::size_type new_size)
Resize the BoundedVector to the specified number of elements.
Definition: bounded_vector.hpp:342
BoundedVector & operator=(std::initializer_list< typename Base::value_type > l)
BoundedVector list assignment operator.
Definition: bounded_vector.hpp:238
friend bool operator!=(const BoundedVector &x, const BoundedVector &y)
Based on operator==.
Definition: bounded_vector.hpp:747
BoundedVector() noexcept(std::is_nothrow_default_constructible< Alloc >::value)
Create a BoundedVector with no elements.
Definition: bounded_vector.hpp:56
void swap(BoundedVector< Tp, UpperBound, Alloc > &x, BoundedVector< Tp, UpperBound, Alloc > &y)
See rosidl_runtime_cpp::BoundedVector::swap().
Definition: bounded_vector.hpp:785
Base::iterator insert(typename Base::const_iterator position, const typename Base::value_type &x)
Insert given value into BoundedVector before specified iterator.
Definition: bounded_vector.hpp:523
BoundedVector(BoundedVector &&x) noexcept
BoundedVector move constructor.
Definition: bounded_vector.hpp:131
friend bool operator<(const BoundedVector &x, const BoundedVector &y)
Vector ordering relation.
Definition: bounded_vector.hpp:738
friend bool operator>=(const BoundedVector &x, const BoundedVector &y)
Based on operator<.
Definition: bounded_vector.hpp:774
friend bool operator<=(const BoundedVector &x, const BoundedVector &y)
Based on operator<.
Definition: bounded_vector.hpp:765
void resize(typename Base::size_type new_size, const typename Base::value_type &x)
Resize the BoundedVector to the specified number of elements.
Definition: bounded_vector.hpp:362
friend bool operator==(const BoundedVector &x, const BoundedVector &y)
Vector equality comparison.
Definition: bounded_vector.hpp:718
Base::iterator emplace(typename Base::const_iterator position, Args &&... args)
Insert an object in BoundedVector before specified iterator.
Definition: bounded_vector.hpp:500
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.
Definition: bounded_vector.hpp:151
Base::iterator insert(typename Base::const_iterator position, typename Base::value_type &&x)
Insert given rvalue into BoundedVector before specified iterator.
Definition: bounded_vector.hpp:546
void push_back(typename Base::value_type &&x)
Definition: bounded_vector.hpp:457
void assign(typename Base::size_type n, const typename Base::value_type &val)
Assign a given value to a BoundedVector.
Definition: bounded_vector.hpp:260
BoundedVector(const typename Base::allocator_type &a) noexcept
Creates a BoundedVector with no elements.
Definition: bounded_vector.hpp:66
BoundedVector(const BoundedVector &x)
BoundedVector copy constructor.
Definition: bounded_vector.hpp:119
BoundedVector & operator=(const BoundedVector &x)
BoundedVector assignment operator.
Definition: bounded_vector.hpp:208
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.
Definition: bounded_vector.hpp:595
A container based on std::vector but with an upper bound.
Definition: bounded_vector.hpp:36
Definition: action_type_support_decl.hpp:21
void reserve(typename Base::size_type n)
Attempt to preallocate enough memory for specified number of elements.
Definition: bounded_vector.hpp:393
Base::size_type max_size() const noexcept
Definition: bounded_vector.hpp:326
auto emplace_back(Args &&... args)
Add data to the end of the BoundedVector.
Definition: bounded_vector.hpp:478
void push_back(const typename Base::value_type &x)
Add data to the end of the BoundedVector.
Definition: bounded_vector.hpp:448
BoundedVector & operator=(BoundedVector &&x)
BoundedVector move assignment operator
Definition: bounded_vector.hpp:219
BoundedVector(InputIterator first, InputIterator last, const typename Base::allocator_type &a=allocator_type())
Build a BoundedVector from a range.
Definition: bounded_vector.hpp:179
BoundedVector(typename Base::size_type n, const typename Base::allocator_type &a=allocator_type())
Create a BoundedVector with default constructed elements.
Definition: bounded_vector.hpp:81
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.
Definition: bounded_vector.hpp:99
T emplace_back(T... args)
Base::iterator insert(typename Base::const_iterator position, InputIterator first, InputIterator last)
Insert a range into the BoundedVector.
Definition: bounded_vector.hpp:625
const T * data() const noexcept
Definition: bounded_vector.hpp:431
void assign(InputIterator first, InputIterator last)
Assign a range to a BoundedVector.
Definition: bounded_vector.hpp:287
T shrink_to_fit(T... args)
friend bool operator>(const BoundedVector &x, const BoundedVector &y)
Based on operator<.
Definition: bounded_vector.hpp:756
void assign(std::initializer_list< typename Base::value_type > l)
Assign an initializer list to a BoundedVector.
Definition: bounded_vector.hpp:306
T * data() noexcept
Return a pointer such that [data(), data() + size()) is a valid range.
Definition: bounded_vector.hpp:418
Base::iterator insert(typename Base::const_iterator position, std::initializer_list< typename Base::value_type > l)
Insert an initializer_list into the BoundedVector.
Definition: bounded_vector.hpp:570