This commit is contained in:
Neargye 2018-09-01 22:19:33 +05:00
parent bfacde30f2
commit 3634092bf2
2 changed files with 6 additions and 6 deletions

View file

@ -385,7 +385,7 @@ template <typename T, int I = 0>
struct NameofEnumImpl { struct NameofEnumImpl {
NAMEOF_CONSTEXPR nameof::cstring operator()(T value) const { NAMEOF_CONSTEXPR nameof::cstring operator()(T value) const {
return (static_cast<int>(value) - I == 0) return (static_cast<int>(value) - I == 0)
? NameofEnumImpl2<T, T(I)>() ? NameofEnumImpl2<T, T(0 + I)>()
: (static_cast<int>(value) >= 0) : (static_cast<int>(value) >= 0)
? NameofEnumImpl<T, I + 1>{}(value) ? NameofEnumImpl<T, I + 1>{}(value)
: NameofEnumImpl<T, I - 1>{}(value); : NameofEnumImpl<T, I - 1>{}(value);

View file

@ -70,7 +70,7 @@ struct Long {
enum class Color { RED = -1, GREEN, BLUE }; enum class Color { RED = -1, GREEN, BLUE };
enum Directions { Up, Down, Right, Left}; enum Directions : int { Up, Down, Right, Left};
SomeStruct struct_var; SomeStruct struct_var;
Long othervar; Long othervar;
@ -145,6 +145,7 @@ TEST_CASE("constexpr") {
REQUIRE(cx6 == "__cplusplus"); REQUIRE(cx6 == "__cplusplus");
} }
#if defined(NAMEOF_HAS_CONSTEXPR)
SECTION("NAMEOF_ENUM") { SECTION("NAMEOF_ENUM") {
constexpr auto cx = NAMEOF_ENUM(color); constexpr auto cx = NAMEOF_ENUM(color);
# if defined(__clang__) || defined(_MSC_VER) # if defined(__clang__) || defined(_MSC_VER)
@ -155,7 +156,6 @@ TEST_CASE("constexpr") {
# endif # endif
} }
#if defined(NAMEOF_TYPE_HAS_CONSTEXPR)
SECTION("NAMEOF_TYPE") { SECTION("NAMEOF_TYPE") {
constexpr auto cx = NAMEOF_TYPE(ptr_c); constexpr auto cx = NAMEOF_TYPE(ptr_c);
# if defined(__clang__) # if defined(__clang__)