diff --git a/include/fixed_containers/concepts.hpp b/include/fixed_containers/concepts.hpp index f0c56288..3b86fa71 100644 --- a/include/fixed_containers/concepts.hpp +++ b/include/fixed_containers/concepts.hpp @@ -154,6 +154,12 @@ struct CompileTimeValuePrinter { }; +template +struct Overloaded : Ts... +{ + using Ts::operator()...; +}; + // a "void-like" type, but without the hassle // e.g. EmptyValue& is a valid type struct EmptyValue diff --git a/test/concepts_test.cpp b/test/concepts_test.cpp index 0e329324..1b6ab3f0 100644 --- a/test/concepts_test.cpp +++ b/test/concepts_test.cpp @@ -2,7 +2,10 @@ #include "fixed_containers/assert_or_abort.hpp" +#include + #include +#include namespace fixed_containers { @@ -51,4 +54,19 @@ static_assert(IsStructuralType); static_assert(ConstexprDefaultConstructible); static_assert(IsNotStructuralType); +TEST(Concepts, Overloaded) +{ + constexpr double RESULT = []() + { + Overloaded overloads{ + [](double) -> double { return 3.0; }, + [](const int&) -> double { return 5.0; }, + }; + + std::variant var1 = 9.0; + return std::visit(overloads, var1); + }(); + + static_assert(RESULT == 3.0); +} } // namespace fixed_containers