|
| | BasicVariant () |
| |
| | BasicVariant (const ALLOC &allocator) |
| |
| template<INDEX I, typename... ARGS, std::enable_if_t<!is_first_allocator_v< ARGS... >> * = nullptr> |
| | BasicVariant (in_place_index_t< I >, ARGS &&... args) |
| |
| template<INDEX I, typename... ARGS> |
| | BasicVariant (in_place_index_t< I >, const ALLOC &allocator, ARGS &&... args) |
| |
| | 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 ()=default |
| |
| 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 |
| |
template<typename ALLOC, typename INDEX, typename... T>
class zserio::BasicVariant< ALLOC, INDEX, T >
Implementation of variant type using BasicAny 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 (by design)
- supplied INDEX type needs to be convertible to/from size_t and std::variant_npos
- holds_alternative() omitted
- get/get_if() exist as member functions as well
Definition at line 102 of file Variant.h.
template<typename ALLOC , typename INDEX , typename... T>
template<INDEX I, typename... ARGS, 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>
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>
Constructs a value of type U at index I with given arguments.
- Parameters
-
| args | Arguments to be forwarded for element construction. |
Definition at line 266 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 314 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 331 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 299 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 286 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 255 of file Variant.h.