10 using variant_type = std::variant<int32_t, bool>;
11 auto std_variant_1 = variant_type{
false};
16 auto std_variant_2 = variant_type{};
19 BOOST_REQUIRE(std_variant_1 == std_variant_2);
24 using variant_type = std::variant<int32_t, bool, std::string>;
26 auto v1 = variant_type{std::string{
"hello world"}};
27 BOOST_CHECK_EXCEPTION(std::get<int32_t>(v1), std::bad_variant_access, [](
const auto& e) {
return true; });
28 auto result1 = std::get<std::string>(v1);
29 BOOST_REQUIRE(result1 == std::string{
"hello world"});
31 const auto v2 = variant_type{std::string{
"hello world"}};
32 BOOST_CHECK_EXCEPTION(std::get<int32_t>(v2), std::bad_variant_access, [](
const auto& e) {
return true; });
33 const auto result2 = std::get<std::string>(v2);
34 BOOST_REQUIRE(result2 == std::string{
"hello world"});
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.