diff --git a/example/example.cpp b/example/example.cpp index ffbe8f1..7cfac34 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -38,6 +38,10 @@ struct Long { LL LLField; }; +struct TestRValue { + int Field; +}; + int someVar = 0; int main() { @@ -62,9 +66,11 @@ int main() { std::cout << NAMEOF_VAR(&SomeStruct::SomeMethod) << std::endl; // SomeMethod std::cout << NAMEOF_VAR(otherVar.LLField.LLLField) << std::endl; // LLLField std::cout << NAMEOF_VAR(&someVar) << std::endl; // someVar + std::cout << NAMEOF_VAR(ptrVar) << std::endl; // ptrVar std::cout << NAMEOF_VAR(*ptrVar) << std::endl; // ptrVar std::cout << NAMEOF_VAR(+innValue) << std::endl; // innValue std::cout << NAMEOF_VAR(-innValue) << std::endl; // innValue std::cout << NAMEOF_VAR(~innValue) << std::endl; // innValue - std::cout << NAMEOF_VAR(!innValue) << std::endl; // unsignedValue + std::cout << NAMEOF_VAR(!innValue) << std::endl; // innValue + std::cout << NAMEOF_VAR(TestRValue()) << std::endl; // TestRValue() } \ No newline at end of file diff --git a/src/nameof.hpp b/src/nameof.hpp index 2d11d8f..327a626 100644 --- a/src/nameof.hpp +++ b/src/nameof.hpp @@ -26,16 +26,11 @@ inline constexpr const char* template_nameof(const char* name, const size_t length) { return length == 0 ? name - : (name[length - 1] == ' ' || - name[length - 1] == '.' || - name[length - 1] == '>' || - name[length - 1] == ':' || - name[length - 1] == '&' || - name[length - 1] == '*' || - name[length - 1] == '+' || - name[length - 1] == '~' || - name[length - 1] == '-' || - name[length - 1] == '!') + : (name[length - 1] == ' ' || name[length - 1] == '.' || + name[length - 1] == '>' || name[length - 1] == ':' || + name[length - 1] == '&' || name[length - 1] == '*' || + name[length - 1] == '+' || name[length - 1] == '~' || + name[length - 1] == '-' || name[length - 1] == '!') ? &name[length] : template_nameof(name, length - 1); }