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
Public Member Functions
arg
at the specified index index
into the underlying sequential container. 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
Constructs an invalid variant_sequential_view object.
- See also
- is_valid()
Constructs a copy of the given variant_sequential_view other
.
Destroys the variant_sequential_view.
- Remarks
- The underlying data is not destroyed.
Member Function Documentation
Returns an iterator to the first element of the container.
- See also
- end()
- Returns
- Iterator to the first element .
Removes all elements from the container.
- Remarks
- Invalidates all references, pointers, or iterators referring to contained elements.
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.
Removes the element (if one exists) at the position pos
.
- Returns
- Iterator following the last removed element.
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.
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
.
Returns the number of elements in the sequential container.
- Returns
- The number of elements in the sequential container.
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()
Insert a value into the container.
- Returns
- An iterator to the inserted element, otherwise an invalid iterator, when the insertion was not possible.
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.
Checks if the container has no elements.
- Returns
true
if container is empty, otherwisefalse
.
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.
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.
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.
Sets the size of the sequential container.
- Returns
true
, when the size of the container could be changed, otherwisefalse
.
- See also
- is_dynamic()
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
.
Swaps this variant_sequential_view with the other variant_sequential_view.
The documentation for this class was generated from the following file: