|
| BasicVariant () |
|
| BasicVariant (const ALLOC &allocator) |
|
template<INDEX I, typename... ARGS, std::enable_if_t<!detail::is_variant_heap_allocated_v< I, T... >> * = nullptr, std::enable_if_t<!is_first_allocator_v< ARGS... >> * = nullptr> |
| BasicVariant (in_place_index_t< I >, ARGS &&... args) |
|
template<INDEX I, typename... ARGS, std::enable_if_t<!detail::is_variant_heap_allocated_v< I, T... >> * = nullptr> |
| BasicVariant (in_place_index_t< I >, const ALLOC &allocator, ARGS &&... args) |
|
template<INDEX I, typename... ARGS, typename U = detail::type_at_t<static_cast<size_t>(I), T...>, std::enable_if_t< detail::is_variant_heap_allocated_v< I, T... >> * = nullptr> |
| BasicVariant (in_place_index_t< I >, const ALLOC &allocator, ARGS &&... args) |
|
template<INDEX I, typename... ARGS, typename U = detail::type_at_t<static_cast<size_t>(I), T...>, std::enable_if_t< detail::is_variant_heap_allocated_v< I, T... >> * = nullptr, std::enable_if_t<!is_first_allocator_v< ARGS... >> * = nullptr> |
| BasicVariant (in_place_index_t< I >, ARGS &&... args) |
|
| ~BasicVariant () |
|
| BasicVariant (const BasicVariant &other) |
|
| BasicVariant (const BasicVariant &other, const ALLOC &allocator) |
|
BasicVariant & | operator= (const BasicVariant &other) |
|
| BasicVariant (BasicVariant &&other) |
|
| BasicVariant (BasicVariant &&other, const ALLOC &allocator) |
|
BasicVariant & | operator= (BasicVariant &&other) |
|
bool | valueless_by_exception () const noexcept |
|
template<INDEX I, typename... ARGS> |
decltype(auto) | emplace (ARGS &&... args) |
|
INDEX | index () const noexcept |
|
template<INDEX I, typename U = detail::type_at_t<I, T...>> |
U * | get_if () noexcept |
|
template<INDEX I, typename U = detail::type_at_t<I, T...>> |
const U * | get_if () const noexcept |
|
template<INDEX I, typename U = detail::type_at_t<I, T...>> |
U & | get () |
|
template<INDEX I, typename U = detail::type_at_t<I, T...>> |
const U & | get () const |
|
void | swap (BasicVariant &other) |
|
template<typename F > |
auto | visit (F &&fun) -> decltype(fun(std::declval< detail::type_at_t< 0, T... >>())) |
|
template<typename F > |
auto | visit (F &&fun) const -> decltype(fun(std::declval< detail::type_at_t< 0, T... >>())) |
|
bool | operator== (const BasicVariant &other) const |
|
bool | operator!= (const BasicVariant &other) const |
|
bool | operator< (const BasicVariant &other) const |
|
bool | operator> (const BasicVariant &other) const |
|
bool | operator<= (const BasicVariant &other) const |
|
bool | operator>= (const BasicVariant &other) const |
|
| AllocatorHolder () |
|
| AllocatorHolder (const allocator_type &allocator) |
|
| AllocatorHolder (allocator_type &&allocator) |
|
allocator_type | get_allocator () const |
|
| ~AllocatorHolder ()=default |
|
| AllocatorHolder (const AllocatorHolder &other)=default |
|
AllocatorHolder & | operator= (const AllocatorHolder &other)=default |
|
| AllocatorHolder (AllocatorHolder &&other)=default |
|
AllocatorHolder & | operator= (AllocatorHolder &&other)=default |
|
template<typename ALLOC, typename INDEX, typename... T>
class zserio::BasicVariant< ALLOC, INDEX, T >
Implementation of variant type which allocates memory when selected type doesn't fit under 3*sizeof(void*)
Largely compatible with std::variant with following differences:
- access only through index whose type has to be specified
- supplied INDEX type needs to be convertible to/from size_t
- holds_alternative() omitted
- variant_npos omitted
- get/get_if() exists as member functions as well
Definition at line 93 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename... ARGS, std::enable_if_t<!detail::is_variant_heap_allocated_v< I, T... >> * = nullptr, std::enable_if_t<!is_first_allocator_v< ARGS... >> * = nullptr>
Constructor with initial emplacement.
- Parameters
-
in_place_index | Index of the active element. |
args | Arguments to be forwarded for element construction. |
- Exceptions
-
can | throw any exception thrown by T[I] |
Definition at line 139 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename... ARGS, std::enable_if_t<!detail::is_variant_heap_allocated_v< I, T... >> * = nullptr>
Constructor with allocator and initial emplacement.
- Parameters
-
in_place_index | Index of the active element. |
allocator | Allocator to be used. |
args | Arguments to be forwarded for element construction. |
- Exceptions
-
can | throw any exception thrown by T[I] |
Definition at line 154 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename... ARGS, typename U = detail::type_at_t<static_cast<size_t>(I), T...>, std::enable_if_t< detail::is_variant_heap_allocated_v< I, T... >> * = nullptr>
Constructor with allocator and initial emplacement.
- Parameters
-
in_place_index | Index of the active element. |
allocator | Allocator to be used. |
args | Arguments to be forwarded for element construction. |
- Exceptions
-
can | throw any exception thrown by T[I] |
Definition at line 170 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename... ARGS, typename U = detail::type_at_t<static_cast<size_t>(I), T...>, std::enable_if_t< detail::is_variant_heap_allocated_v< I, T... >> * = nullptr, std::enable_if_t<!is_first_allocator_v< ARGS... >> * = nullptr>
Constructor with initial emplacement.
- Parameters
-
in_place_index | Index of the active element. |
args | Arguments to be forwarded for element construction. |
- Exceptions
-
can | throw any exception thrown by T[I] |
Definition at line 186 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename... ARGS>
Sets any value to variant.
- Parameters
-
args | Arguments to be forwarded for element construction. |
Definition at line 324 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename U = detail::type_at_t<I, T...>>
Returns element at index I. Throws if index doesn't match
- Exceptions
-
Definition at line 402 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename U = detail::type_at_t<I, T...>>
Returns element at index I. Throws if index doesn't match
- Exceptions
-
Definition at line 419 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename U = detail::type_at_t<I, T...>>
Returns a pointer to an element at index I or nullptr if index doesn't match.
Definition at line 380 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename U = detail::type_at_t<I, T...>>
Returns a pointer to an element at index I or nullptr if index doesn't match.
Definition at line 360 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
Reports if variant is in nonstandard empty state. Note: which operations lead to an empty state is not specified by ISO C++
As an zserio extension, the valueless state can arise after move. This happens only When the held alternative is stored on the heap, and the used allocator is the same in both variants. In that case, the underlying pointer is stolen and the moved-out variant remains in the valueless state.
Definition at line 305 of file Variant.h.