Full example for cetl::unbounded_variant
#include <gmock/gmock.h>
TEST(example_10_unbounded_variant, basic_usage)
{
ub_var a = 1;
a = 3.14;
a = true;
a = 1;
#ifdefined(__cpp_exceptions)
const auto sink = [](auto&&) {};
#else
#endif
a = 2;
EXPECT_TRUE(a.has_value());
a.reset();
EXPECT_FALSE(a.has_value());
a = 3;
}
Defines a type of object to be thrown by the get on failure.
Definition unbounded_variant.hpp:31
The class unbounded_variant describes a type-safe container for single values of unbounded_variant co...
Definition unbounded_variant.hpp:1029
CETL_NODISCARD std::add_pointer_t< std::add_const_t< ValueType > > get_if(const UbVar< Footprint, Copyable, Movable, Alignment, Pmr > *const operand) noexcept
Performs type-safe access to the const contained object.
Definition unbounded_variant.hpp:1652
CETL_NODISCARD const ValueType & get(const UbVar< Footprint, Copyable, Movable, Alignment, Pmr > &operand)
Performs type-safe access to the contained object.
Definition unbounded_variant.hpp:1721
Includes cetl::unbounded_variant type and non-member functions.