23 {
24 using variant_type = std::variant<int32_t, bool, std::string>;
25
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"});
30
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"});
35 }