diff --git a/include/cista/containers/variant.h b/include/cista/containers/variant.h index 9c4c2a4b..57b13020 100755 --- a/include/cista/containers/variant.h +++ b/include/cista/containers/variant.h @@ -438,6 +438,11 @@ using cista::variant; namespace std { +template +constexpr auto visit(Visitor&& vis, cista::variant&& v) { + v.apply(vis); +} + using cista::get; } // namespace std diff --git a/test/variant_test.cc b/test/variant_test.cc index 631a54e9..570503b9 100755 --- a/test/variant_test.cc +++ b/test/variant_test.cc @@ -241,3 +241,15 @@ TEST_CASE("variant get_if") { REQUIRE(str != nullptr); CHECK(*str == "hello test test test test"); } + +TEST_CASE("std visit") { + std::visit( + [](auto&& x) { + if constexpr (std::is_same_v>) { + CHECK(true); + } else { + CHECK(false); + } + }, + cista::variant{1}); +}