#include <gmock/gmock.h>
{
template <>
{
return {1};
}
template <>
{
return {2};
}
template <>
{
return {3};
}
template <>
{
return {4};
}
}
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:30
The class unbounded_variant describes a type-safe container for single values of unbounded_variant co...
Definition unbounded_variant.hpp:1032
This namespace contains types specific to CETL and nested namespaces that contain types adhering to t...
Definition _helper_enable_copy_move.hpp:10
constexpr type_id type_id_getter() noexcept
The type ID getter for the given type.
Definition rtti.hpp:85
std::add_pointer_t< ValueType > get_if(UnboundedVariant *operand) noexcept
Performs type-safe access to the contained object.
Definition unbounded_variant.hpp:1720
CETL_NODISCARD ValueType get(const UnboundedVariant &operand)
Performs type-safe access to the contained object.
Definition unbounded_variant.hpp:1625
std::array< std::uint8_t, type_id_size > type_id
A 16-byte UUID (GUID) that uniquely identifies a type.
Definition rtti.hpp:32
Includes cetl::unbounded_variant type and non-member functions.