diff --git a/examples/unittests.cpp b/examples/unittests.cpp index 481d445c..231f0286 100644 --- a/examples/unittests.cpp +++ b/examples/unittests.cpp @@ -48,7 +48,6 @@ enum class numbers : int { zero, one, two, three, four, five, FIVE=five, six, se TEST_CASE("is_valid") { REQUIRE(conjure_enum::is_valid()); - REQUIRE(conjure_enum::is_valid()); REQUIRE(!conjure_enum::is_valid(100)>()); REQUIRE(conjure_enum::is_valid()); REQUIRE(!conjure_enum::is_valid(100)>()); @@ -260,7 +259,6 @@ TEST_CASE("for_each") TEST_CASE("enum_bitset") { enum_bitset eb; - //enum_bitset ebr; eb.set_all(); REQUIRE(eb.test_all()); eb.reset(); // use alias diff --git a/include/fix8/conjure_enum.hpp b/include/fix8/conjure_enum.hpp index 28298add..adfdac9f 100644 --- a/include/fix8/conjure_enum.hpp +++ b/include/fix8/conjure_enum.hpp @@ -37,10 +37,10 @@ // static const char *FIX8::conjure_enum::tpeek() [T = component] // |<-- -->| // gcc -// static consteval const char* FIX8::conjure_enum::epeek() [with T e = component::path; E = component; T = component] // valid -// |<-- -->| -// static consteval const char* FIX8::conjure_enum::epeek() [with T e = (component)100; E = component; T = component] // invalid -// |<-- -->| +// static consteval const char* FIX8::conjure_enum::epeek() [with T e = component::path; T = component] // valid +// |<-- -->| +// static consteval const char* FIX8::conjure_enum::epeek() [with T e = (component)100; T = component] // invalid +// |<-- -->| // static consteval const char* FIX8::conjure_type::tpeek() [with T = component] // |<-- -->| // msvc @@ -120,8 +120,8 @@ constexpr auto get_spec() noexcept } //----------------------------------------------------------------------------------------- -template> -requires std::is_enum_v +template +requires std::same_as> && std::is_enum_v class conjure_enum final { static constexpr int enum_min_value{ENUM_MIN_VALUE}, enum_max_value{ENUM_MAX_VALUE}; @@ -219,7 +219,7 @@ class conjure_enum final static constexpr std::string_view _get_name() noexcept { constexpr std::string_view from{epeek()}; - if (constexpr auto ep { from.rfind(get_spec<0,0>()) }; ep != std::string_view::npos && from[ep + get_spec<0,0>().size()] != '(') + if constexpr (constexpr auto ep { from.rfind(get_spec<0,0>()) }; ep != std::string_view::npos && from[ep + get_spec<0,0>().size()] != '(') { constexpr std::string_view result { from.substr(ep + get_spec<0,0>().size()) }; if constexpr (constexpr auto lc { result.find_first_of(get_spec<1,0>()) }; lc != std::string_view::npos) @@ -262,8 +262,9 @@ class conjure_enum final } struct is_scoped : std::integral_constant>; }> - {}; + { + requires !std::convertible_to>; + }>{}; template static constexpr bool is_valid() noexcept { return !_get_name().empty(); } @@ -376,8 +377,10 @@ struct iterator_adaptor // Note: your enum sequence must be continuous with the last enum value < count of enumerations //----------------------------------------------------------------------------------------- template -concept valid_bitset_enum = std::is_enum_v> && requires(T) +concept valid_bitset_enum = requires(T) { + requires std::is_enum_v; + requires std::same_as>; requires conjure_enum::count() > 0; requires static_cast(conjure_enum::values.back()) < conjure_enum::count(); };