14 std::variant<std::monostate, int, std::string> var = 10;
18 [](int) { REQUIRE(
true); },
19 [](
const std::string&) { REQUIRE(
false); }},
24 var, [](std::monostate) { REQUIRE(
false); }, [](int) { REQUIRE(
true); },
25 [](
const std::string&) { REQUIRE(
false); });
28 kblib::visit(var)([](std::monostate) { REQUIRE(
false); },
29 [](int) { REQUIRE(
true); },
30 [](
const std::string&) { REQUIRE(
false); });
36 std::variant<std::monostate, int, std::string> var = 10;
40 [](int) { REQUIRE(
true); },
41 [](
const std::string&) { REQUIRE(
false); }},
46 var, [](std::monostate) { REQUIRE(
false); }, [](int) { REQUIRE(
true); },
47 [](
const std::string&) { REQUIRE(
false); });
51 std::variant<std::monostate, int, std::string> var(std::in_place_type<int>,
54 REQUIRE(constant == 1);
56 std::is_same_v<
decltype(val),
57 std::variant_alternative_t<constant,
decltype(var)>>);
62 std::variant<int, std::string> from(std::in_place_type<int>, 10);
64 = kblib::variant_cast<std::variant<std::monostate, int, std::string>>(
66 REQUIRE(to.index() == 1);
Provides generic facilities for hashing data, and aliases for standard unordered containers using the...
constexpr auto visit_indexed(Variant &&variant, Fs &&... fs) -> decltype(auto)
Visit a variant, but pass the index (as an integral_constant) to the visitor. This allows for a visit...
constexpr auto visit2(V &&v, F &&f, Fs &&... fs) -> decltype(auto)
constexpr auto visit(V &&v, F &&f, Fs &&... fs) -> decltype(auto)
Wraps std::visit to provide an interface taking one variant and any number of functors providing an o...
Helper class for std::visiting a std::variant.
Provides utilities for working with std::variant more expressively and more efficiently.