From 87092f7b1dbeb8035176dd87b79ead5a6f04b406 Mon Sep 17 00:00:00 2001 From: terik23 Date: Sat, 31 Mar 2018 00:29:53 +0500 Subject: [PATCH] removed redundant aliases --- README.md | 7 ------- example/example.cpp | 10 +--------- src/nameof.hpp | 12 ------------ test/test.cpp | 24 ++++++++++++------------ 4 files changed, 13 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index d0bb1dd..f0258fb 100644 --- a/README.md +++ b/README.md @@ -34,12 +34,6 @@ NAMEOF(someVar.SomeField) -> "SomeField" NAMEOF(someVar.SomeMethod1()) -> "SomeMethod1()" NAMEOF(&SomeStruct::SomeMethod2) -> "SomeMethod2" - -NAMEOF_FUNCTION(someVar.SomeMethod1()) -> "SomeMethod1()" -NAMEOF_FUNCTION(&SomeStruct::SomeMethod2) -> "SomeMethod2" - -NAMEOF_VAR(someVar) -> "someVar" -NAMEOF_VAR(someVar.SomeField) -> "SomeField" ``` * Name of enum @@ -54,7 +48,6 @@ NAMEOF(SomeEnum::GREEN) -> "GREEN" ```cpp NAMEOF_TYPE(int[]) -> "int[]" NAMEOF_TYPE(std::string) -> "string" -NAMEOF_TYPE(std::stringgg) -> error namespace "std" has no member "stringgg" ``` * Constexpr diff --git a/example/example.cpp b/example/example.cpp index c5583de..9a6c275 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -81,14 +81,6 @@ void TestCase1() { std::cout << NAMEOF_TYPE(SomeStruct) << std::endl; // SomeStruct std::cout << NAMEOF_TYPE(Long::LL) << std::endl; // LL - std::cout << NAMEOF_FUN(someVar.SomeMethod1()) << std::endl; // SomeMethod1() - std::cout << NAMEOF_FUN(&SomeStruct::SomeMethod2) << std::endl; // SomeMethod2 - std::cout << NAMEOF_FUN(SomeMethod3) << std::endl; // SomeMethod3 - - std::cout << NAMEOF_VAR(someVar.SomeField) << std::endl; // SomeField - std::cout << NAMEOF_VAR((&someVar)->SomeField) << std::endl; // SomeField - std::cout << NAMEOF_VAR(::someVar) << std::endl; // someVar - std::cout << NAMEOF_FULL(someVar.SomeField) << std::endl; // someVar.SomeField std::cout << NAMEOF_FULL(&SomeStruct::SomeMethod2) << std::endl; // &SomeStruct::SomeMethod2 } @@ -110,7 +102,7 @@ void TestCase2() { } void TestCase3() { - std::cout << NAMEOF_FUNCTION(TestCase3) << " method entry" << std::endl; // TestCase3 method entry + std::cout << NAMEOF(TestCase3) << " method entry" << std::endl; // TestCase3 method entry } int main() { diff --git a/src/nameof.hpp b/src/nameof.hpp index e8b0550..16ce444 100644 --- a/src/nameof.hpp +++ b/src/nameof.hpp @@ -49,18 +49,6 @@ constexpr const char* Nameof(const char* name, const size_t length) { #define NAMEOF_FULL(name) nameof::Nameof(NAMEOF_RAW(name), 0) -#define NAMEOF_VARIABLE(variable) NAMEOF(variable) -#define NAMEOF_VAR(var) NAMEOF(var) - -#define NAMEOF_VARIABLE_FULL(variable) NAMEOF_FULL(variable) -#define NAMEOF_VAR_FULL(var) NAMEOF_FULL(var) - -#define NAMEOF_FUNCTION(function) NAMEOF(function) -#define NAMEOF_FUN(fun) NAMEOF(fun) - -#define NAMEOF_FUNCTION_FULL(function) NAMEOF_FULL(function) -#define NAMEOF_FUN_FULL(fun) NAMEOF_FULL(fun) - // Used to obtain the string name of a type. #define NAMEOF_TYPE(type) nameof::Nameof(NAMEOF_RAW(type), sizeof(NAMEOF_RAW(type)) / sizeof(char) - 1) diff --git a/test/test.cpp b/test/test.cpp index 3a7a176..4a49a80 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -86,15 +86,15 @@ TEST_CASE("NAMEOF") { } SECTION("NAMEOF_VARIABLE") { - REQUIRE(std::strcmp(NAMEOF_VARIABLE(someVar.SomeField), "SomeField") == 0); - REQUIRE(std::strcmp(NAMEOF_VARIABLE((&someVar)->SomeField), "SomeField") == 0); - REQUIRE(std::strcmp(NAMEOF_VARIABLE(::someVar), "someVar") == 0); + REQUIRE(std::strcmp(NAMEOF(someVar.SomeField), "SomeField") == 0); + REQUIRE(std::strcmp(NAMEOF((&someVar)->SomeField), "SomeField") == 0); + REQUIRE(std::strcmp(NAMEOF(::someVar), "someVar") == 0); } SECTION("NAMEOF_FUNCTION") { - REQUIRE(std::strcmp(NAMEOF_FUNCTION(someVar.SomeMethod1()), "SomeMethod1()") == 0); - REQUIRE(std::strcmp(NAMEOF_FUNCTION(&SomeStruct::SomeMethod2), "SomeMethod2") == 0); - REQUIRE(std::strcmp(NAMEOF_FUNCTION(SomeMethod3), "SomeMethod3") == 0); + REQUIRE(std::strcmp(NAMEOF(someVar.SomeMethod1()), "SomeMethod1()") == 0); + REQUIRE(std::strcmp(NAMEOF(&SomeStruct::SomeMethod2), "SomeMethod2") == 0); + REQUIRE(std::strcmp(NAMEOF(SomeMethod3), "SomeMethod3") == 0); } } @@ -135,15 +135,15 @@ TEST_CASE("NAMEOF_FULL") { } SECTION("NAMEOF_VARIABLE_FULL") { - REQUIRE(std::strcmp(NAMEOF_VARIABLE_FULL(someVar.SomeField), "someVar.SomeField") == 0); - REQUIRE(std::strcmp(NAMEOF_VARIABLE_FULL((&someVar)->SomeField), "(&someVar)->SomeField") == 0); - REQUIRE(std::strcmp(NAMEOF_VARIABLE_FULL(::someVar), "::someVar") == 0); + REQUIRE(std::strcmp(NAMEOF_FULL(someVar.SomeField), "someVar.SomeField") == 0); + REQUIRE(std::strcmp(NAMEOF_FULL((&someVar)->SomeField), "(&someVar)->SomeField") == 0); + REQUIRE(std::strcmp(NAMEOF_FULL(::someVar), "::someVar") == 0); } SECTION("NAMEOF_FUNCTION_FULL") { - REQUIRE(std::strcmp(NAMEOF_FUNCTION_FULL(someVar.SomeMethod1()), "someVar.SomeMethod1()") == 0); - REQUIRE(std::strcmp(NAMEOF_FUNCTION_FULL(&SomeStruct::SomeMethod2), "&SomeStruct::SomeMethod2") == 0); - REQUIRE(std::strcmp(NAMEOF_FUNCTION_FULL(SomeMethod3), "SomeMethod3") == 0); + REQUIRE(std::strcmp(NAMEOF_FULL(someVar.SomeMethod1()), "someVar.SomeMethod1()") == 0); + REQUIRE(std::strcmp(NAMEOF_FULL(&SomeStruct::SomeMethod2), "&SomeStruct::SomeMethod2") == 0); + REQUIRE(std::strcmp(NAMEOF_FULL(SomeMethod3), "SomeMethod3") == 0); } }