16#ifndef IOX2_BB_VOCABULARY_VARIANT_HPP
17#define IOX2_BB_VOCABULARY_VARIANT_HPP
100template <
typename...
Types>
104 static constexpr uint64_t TYPE_SIZE { std::max({
sizeof(
Types)... }) };
106 static constexpr uint64_t TYPE_ALIGNMENT { std::max({
alignof(
Types)... }) };
284 char data[TYPE_SIZE];
286 storage_t m_storage {};
290 template <
typename T>
295 void call_element_destructor()
noexcept;
326#include "iox2/legacy/detail/variant.inl"
Variant implementation from the C++17 standard with C++11. The interface is inspired by the C++17 sta...
const T * get() const noexcept
returns a pointer to the type T stored in the variant. (not stl compliant)
void emplace(CTorArguments &&... args) noexcept
calls the constructor of the type T and perfectly forwards the arguments to the constructor of T.
T * get_if(T *defaultValue) noexcept
returns a pointer to the type T if its stored in the variant otherwise it returns the provided defaul...
constexpr uint64_t index() const noexcept
returns the index of the stored type in the variant. if the variant does not contain any type it retu...
void emplace_at_index(CTorArguments &&... args) noexcept
calls the constructor of the type at index TypeIndex and perfectly forwards the arguments to this con...
internal::get_type_at_index< 0, TypeIndex, Types... >::type * unsafe_get_at_index_unchecked() noexcept
returns a pointer to the type stored at index TypeIndex. (not stl compliant)
internal::get_type_at_index< 0, TypeIndex, Types... >::type * get_at_index() noexcept
returns a pointer to the type stored at index TypeIndex. (not stl compliant)
constexpr variant() noexcept=default
the default constructor constructs a variant which does not contain an element and returns INVALID_VA...
constexpr bool holds_alternative(const variant< Types... > &variant) noexcept
returns true if the variant holds a given type T, otherwise false
constexpr bool always_false_v
Helper value to bind a static_assert to a type.
static constexpr uint64_t INVALID_VARIANT_INDEX
value which an invalid variant index occupies
helper struct to perform an emplacement at a predefined index in the constructor of a variant
static constexpr uint64_t value
helper struct to perform an emplacement of a predefined type in in the constructor of a variant