diff --git a/include/cetl/pf17/variant.hpp b/include/cetl/pf17/variant.hpp index df4cf233..480bc4e9 100644 --- a/include/cetl/pf17/variant.hpp +++ b/include/cetl/pf17/variant.hpp @@ -10,10 +10,12 @@ #include #include +#include #include #include #include +#include #include #include // We need this even if exceptions are disabled for std::terminate. #include @@ -25,6 +27,18 @@ namespace pf17 /// Implementation of \ref std::variant_npos. constexpr std::size_t variant_npos = std::numeric_limits::max(); +/// Implementation of \ref std::monostate. +struct monostate +{}; +// clang-format off +inline constexpr bool operator==(const monostate, const monostate) noexcept { return true; } +inline constexpr bool operator!=(const monostate, const monostate) noexcept { return false; } +inline constexpr bool operator< (const monostate, const monostate) noexcept { return false; } +inline constexpr bool operator> (const monostate, const monostate) noexcept { return false; } +inline constexpr bool operator<=(const monostate, const monostate) noexcept { return true; } +inline constexpr bool operator>=(const monostate, const monostate) noexcept { return true; } +// clang-format on + namespace detail { namespace var @@ -32,6 +46,26 @@ namespace var template using nth_type = std::tuple_element_t>; +/// An internal helper used to keep the list of the variant types and query their properties. +template +struct types final +{ + template