RTI Connext Modern C++ API  Version 5.2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dds::core::vector< T > Class Template Reference

<<value-type>> A vector convertible to std::vector and with similar functionality More...

#include <dds/core/vector.hpp>

Public Member Functions

 vector ()
 Creates an empty vector.
 
 vector (size_type initial_size)
 Creates a vector with a number of default-constructed elements.
 
 vector (size_type initial_size, const T &value)
 Creates a vector with a number of copies of a value.
 
 vector (const vector &other)
 Creates a copy.
 
 vector (const std::vector< T > &other)
 Implicit construction from std::vector.
 
 vector (vector &&other) OMG_NOEXCEPT
 Creates a vector by moving an existing one.
 
 operator std::vector< T > () const
 Provides a conversion to std::vector.
 
size_type size () const
 Get the current size.
 
size_type capacity () const
 Get the current capacity.
 
void resize (size_type new_size)
 Set the size to new_size.
 
void resize (size_type new_size, const T &value)
 Set the size to new_size, copying value if new elements are added.
 
void clear ()
 Resize to zero.
 
void reserve (size_type new_capacity)
 Reserve a new capacity without creating any elements or changing the size.
 
reference at (size_type i)
 Get an element by reference and check bounds.
 
const_reference at (size_type i) const
 Get an element by const-reference and check bounds.
 
reference operator[] (size_type i)
 Get an element by reference.
 
const_reference operator[] (size_type i) const
 Get an element by const-reference.
 
vectoroperator= (const vector &other)
 Assign another vector to this one.
 
vectoroperator= (vector &&other) OMG_NOEXCEPT
 Move-assign another vector to this one.
 
bool operator== (const vector &other) const
 Returns if the elements of two vectors are equal.
 
bool operator!= (const vector &other) const
 Returns if two vectors are different.
 
iterator begin ()
 Iterator to the first element.
 
const_iterator begin () const
 Const iterator to first element.
 
iterator end ()
 Iterator to last element plus one.
 
const_iterator end () const
 Const iterator to last element plus one.
 

Friends

void swap (vector &left, vector &right) OMG_NOEXCEPT
 Efficiently swaps the contents of two vectors.
 

Related Functions

(Note that these are not member functions.)

template<typename _Tp >
std::ostream & operator<< (std::ostream &out, const vector< _Tp > &vector)
 Print a vector applying << to all of its elements.
 

Detailed Description

template<typename T>
class dds::core::vector< T >

<<value-type>> A vector convertible to std::vector and with similar functionality

In many cases, for performance reasons and other implementation requirements, the RTI Connext API uses dds::core::vector instead of std::vector. The most significant case is the C++ types that rtiddsgen generates from IDL.

A dds::core::vector provides a subset of the functionality of a std::vector, including iterators, resizing and indexed access. It also provides automatic conversion to and from std::vector, making code like the following possible:

// IDL-generated type
class Foo {
public:
// ...
const dds::core::vector<int32_t>& my_ints() const;
};
// Application
Foo sample = ...;
dds::vector<int32_t> my_std_vector = sample.my_ints(); // conversion to std::vector
// ...
sample.my_ints() = my_std_vector; // conversion from std::vector

Constructor & Destructor Documentation

template<typename T>
dds::core::vector< T >::vector ( )
inline

Creates an empty vector.

template<typename T>
dds::core::vector< T >::vector ( size_type  initial_size)
inlineexplicit

Creates a vector with a number of default-constructed elements.

template<typename T>
dds::core::vector< T >::vector ( size_type  initial_size,
const T &  value 
)
inline

Creates a vector with a number of copies of a value.

template<typename T>
dds::core::vector< T >::vector ( const vector< T > &  other)
inline

Creates a copy.

template<typename T>
dds::core::vector< T >::vector ( const std::vector< T > &  other)
inline

Implicit construction from std::vector.

Note: this operation makes a copy of all the elements in other

template<typename T>
dds::core::vector< T >::vector ( vector< T > &&  other)
inline

Creates a vector by moving an existing one.

Member Function Documentation

template<typename T>
dds::core::vector< T >::operator std::vector< T > ( ) const
inline

Provides a conversion to std::vector.

Note: this operation makes a copy of all the elements in this vector

template<typename T>
size_type dds::core::vector< T >::size ( ) const
inline

Get the current size.

template<typename T>
size_type dds::core::vector< T >::capacity ( ) const
inline

Get the current capacity.

template<typename T>
void dds::core::vector< T >::resize ( size_type  new_size)
inline

Set the size to new_size.

template<typename T>
void dds::core::vector< T >::resize ( size_type  new_size,
const T &  value 
)
inline

Set the size to new_size, copying value if new elements are added.

template<typename T>
void dds::core::vector< T >::clear ( )
inline

Resize to zero.

template<typename T>
void dds::core::vector< T >::reserve ( size_type  new_capacity)
inline

Reserve a new capacity without creating any elements or changing the size.

template<typename T>
reference dds::core::vector< T >::at ( size_type  i)
inline

Get an element by reference and check bounds.

Exceptions
std::out_of_rangeif i is out of bounds
template<typename T>
const_reference dds::core::vector< T >::at ( size_type  i) const
inline

Get an element by const-reference and check bounds.

Exceptions
std::out_of_rangeif i is out of bounds
template<typename T>
reference dds::core::vector< T >::operator[] ( size_type  i)
inline

Get an element by reference.

template<typename T>
const_reference dds::core::vector< T >::operator[] ( size_type  i) const
inline

Get an element by const-reference.

template<typename T>
vector& dds::core::vector< T >::operator= ( const vector< T > &  other)
inline

Assign another vector to this one.

template<typename T>
vector& dds::core::vector< T >::operator= ( vector< T > &&  other)
inline

Move-assign another vector to this one.

template<typename T>
bool dds::core::vector< T >::operator== ( const vector< T > &  other) const
inline

Returns if the elements of two vectors are equal.

template<typename T>
bool dds::core::vector< T >::operator!= ( const vector< T > &  other) const
inline

Returns if two vectors are different.

template<typename T>
iterator dds::core::vector< T >::begin ( )
inline

Iterator to the first element.

template<typename T>
const_iterator dds::core::vector< T >::begin ( ) const
inline

Const iterator to first element.

template<typename T>
iterator dds::core::vector< T >::end ( )
inline

Iterator to last element plus one.

template<typename T>
const_iterator dds::core::vector< T >::end ( ) const
inline

Const iterator to last element plus one.

Friends And Related Function Documentation

template<typename T>
void swap ( vector< T > &  left,
vector< T > &  right 
)
friend

Efficiently swaps the contents of two vectors.

template<typename _Tp >
std::ostream & operator<< ( std::ostream &  out,
const vector< _Tp > &  vector 
)
related

Print a vector applying << to all of its elements.


RTI Connext Modern C++ API Version 5.2.0 Copyright © Sun Jun 21 2015 Real-Time Innovations, Inc