The variant_sequential_view describes a class that refers to an sequence container (e.g: std::vector
) inside a variant.
More...
#include <variant_sequential_view.h>
Classes | |
class | const_iterator |
The variant_sequential_view::const_iterator allows iteration over an sequential container in a variant. More... | |
Public Member Functions | |
variant_sequential_view () | |
Constructs an invalid variant_sequential_view object. More... | |
variant_sequential_view (const variant_sequential_view &other) | |
Constructs a copy of the given variant_sequential_view other . More... | |
~variant_sequential_view () noexcept | |
Destroys the variant_sequential_view. More... | |
const_iterator | begin () const |
Returns an iterator to the first element of the container. More... | |
void | clear () |
Removes all elements from the container. More... | |
const_iterator | end () const |
Returns an iterator to the element following the last element of the container. More... | |
const_iterator | erase (const const_iterator &pos) |
Removes the element (if one exists) at the position pos . More... | |
std::size_t | get_rank () const noexcept |
Gets the rank (number of dimensions) of this sequential container. More... | |
type | get_rank_type (std::size_t index) const noexcept |
Gets the type of the given rank index. More... | |
std::size_t | get_size () const noexcept |
Returns the number of elements in the sequential container. More... | |
type | get_type () const noexcept |
Returns the type object of this sequential container. More... | |
variant | get_value (std::size_t index) const |
Returns the current value at index index . More... | |
type | get_value_type () const noexcept |
Returns the type object from the value of this sequential container. More... | |
const_iterator | insert (const const_iterator &pos, argument value) |
Insert a value into the container. More... | |
bool | is_dynamic () const noexcept |
Returns true if this sequential view is dynamic, otherwise false . More... | |
bool | is_empty () const noexcept |
Checks if the container has no elements. More... | |
bool | is_valid () const noexcept |
Returns true if this variant_sequential_view is valid, that means the object is holding some data. More... | |
operator bool () const noexcept | |
Convenience function to check if this variant_sequential_view is valid or not. More... | |
variant_sequential_view & | operator= (const variant_sequential_view &other) noexcept |
Assigns the value of the other variant_sequential_view to this variant_sequential_view. More... | |
bool | set_size (std::size_t size) const noexcept |
Sets the size of the sequential container. More... | |
bool | set_value (std::size_t index, argument arg) |
Set the content of the the argument arg at the specified index index into the underlying sequential container. More... | |
void | swap (variant_sequential_view &other) noexcept |
Swaps this variant_sequential_view with the other variant_sequential_view. More... | |
Detailed Description
The variant_sequential_view describes a class that refers to an sequence container (e.g: std::vector
) inside a variant.
With an instance of that class you can set/get values of such container, without having access to the type declaration of the type or it's elements.
A variant_sequential_view can be created directly from a variant with its member function create_sequential_view().
- Remarks
- The instance of an variant_sequential_view is always valid as long as the referenced variant is valid, otherwise accessing a variant_sequential_view is undefined behaviour.
Meta Information
RTTR recognize whether a type is an sequential container or not with the help of the sequential_container_mapper class template. This call can access different container types via one common interface. At the moment there exist specializations for following types: std::vector<T>
, std::array<T, std::size_t>
, std::list<T>
, std::deque<T>
, std::initializer_list<T>
and raw arrays
Copying and Assignment
A variant_sequential_view object can be copied and assigned, however each copy will reference the data of same underlying variant value.
Typical Usage
Output:
- See also
- variant, type::is_sequential_container()
Constructor & Destructor Documentation
rttr::variant_sequential_view::variant_sequential_view | ( | ) |
Constructs an invalid variant_sequential_view object.
- See also
- is_valid()
rttr::variant_sequential_view::variant_sequential_view | ( | const variant_sequential_view & | other | ) |
Constructs a copy of the given variant_sequential_view other
.
|
noexcept |
Destroys the variant_sequential_view.
- Remarks
- The underlying data is not destroyed.
Member Function Documentation
const_iterator rttr::variant_sequential_view::begin | ( | ) | const |
Returns an iterator to the first element of the container.
- See also
- end()
- Returns
- Iterator to the first element .
void rttr::variant_sequential_view::clear | ( | ) |
Removes all elements from the container.
- Remarks
- Invalidates all references, pointers, or iterators referring to contained elements.
const_iterator rttr::variant_sequential_view::end | ( | ) | const |
Returns an iterator to the element following the last element of the container.
- See also
- begin()
- Returns
- Iterator to the element following the last element.
const_iterator rttr::variant_sequential_view::erase | ( | const const_iterator & | pos | ) |
Removes the element (if one exists) at the position pos
.
- Returns
- Iterator following the last removed element.
|
noexcept |
Gets the rank (number of dimensions) of this sequential container.
Take a look at following return values:
=>int
[4]1
=>int
[4][4]2
=>int
[4][4][4]3
- ...
- Returns
- Returns the rank of the sequential container.
|
noexcept |
Gets the type of the given rank index.
Take a look at following return value for an array of type: int[2][10]
=>get_rank_type(0)
int[2][10]
=>get_rank_type(1)
int[10]
=>get_rank_type(2)
int
=> INVALIDget_rank_type(3)
- Returns
- The rank type at the given dimension
index
.
|
noexcept |
Returns the number of elements in the sequential container.
- Returns
- The number of elements in the sequential container.
|
noexcept |
variant rttr::variant_sequential_view::get_value | ( | std::size_t | index | ) | const |
Returns the current value at index index
.
- Returns
- The data at the specified index
index
, wrapped inside astd::reference_wrapper<T>
.
- Remarks
- Make sure the index is in a valid range, otherwise undefined behaviour may occurr.
- See also
- get_size()
|
noexcept |
const_iterator rttr::variant_sequential_view::insert | ( | const const_iterator & | pos, |
argument | value | ||
) |
Insert a value into the container.
- Returns
- An iterator to the inserted element, otherwise an invalid iterator, when the insertion was not possible.
|
noexcept |
Returns true
if this sequential view is dynamic, otherwise false
.
When an sequential view is dynamic, it is possible to change its size, clear its content or insert and erase values from it.
- See also
- set_size(), insert(), erase(), clear()
- Returns
- A boolean flag which indicates whether this sequential container is dynamic or not.
|
noexcept |
Checks if the container has no elements.
- Returns
true
if container is empty, otherwisefalse
.
|
noexcept |
Returns true if this variant_sequential_view is valid, that means the object is holding some data.
When the variant_sequential_view doesn't hold any data it will return false.
- Returns
- True if this variant_sequential_view is valid, otherwise false.
|
explicitnoexcept |
Convenience function to check if this variant_sequential_view is valid or not.
- See also
- is_valid()
- Returns
- True if this variant_sequential_view is valid, otherwise false.
|
noexcept |
Assigns the value of the other variant_sequential_view to this variant_sequential_view.
- Returns
- A reference to the variant_sequential_view with the new data.
|
noexcept |
Sets the size of the sequential container.
- Returns
true
, when the size of the container could be changed, otherwisefalse
.
- See also
- is_dynamic()
bool rttr::variant_sequential_view::set_value | ( | std::size_t | index, |
argument | arg | ||
) |
Set the content of the the argument arg
at the specified index index
into the underlying sequential container.
- Returns
true
if the value could be set, otherwisefalse
.
|
noexcept |
Swaps this variant_sequential_view with the other variant_sequential_view.
The documentation for this class was generated from the following file: