removed redundant aliases

This commit is contained in:
terik23 2018-03-31 00:29:53 +05:00
parent 701befbed8
commit 87092f7b1d
4 changed files with 13 additions and 40 deletions

View file

@ -34,12 +34,6 @@ NAMEOF(someVar.SomeField) -> "SomeField"
NAMEOF(someVar.SomeMethod1()) -> "SomeMethod1()" NAMEOF(someVar.SomeMethod1()) -> "SomeMethod1()"
NAMEOF(&SomeStruct::SomeMethod2) -> "SomeMethod2" 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 * Name of enum
@ -54,7 +48,6 @@ NAMEOF(SomeEnum::GREEN) -> "GREEN"
```cpp ```cpp
NAMEOF_TYPE(int[]) -> "int[]" NAMEOF_TYPE(int[]) -> "int[]"
NAMEOF_TYPE(std::string) -> "string" NAMEOF_TYPE(std::string) -> "string"
NAMEOF_TYPE(std::stringgg) -> error namespace "std" has no member "stringgg"
``` ```
* Constexpr * Constexpr

View file

@ -81,14 +81,6 @@ void TestCase1() {
std::cout << NAMEOF_TYPE(SomeStruct) << std::endl; // SomeStruct std::cout << NAMEOF_TYPE(SomeStruct) << std::endl; // SomeStruct
std::cout << NAMEOF_TYPE(Long::LL) << std::endl; // LL 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(someVar.SomeField) << std::endl; // someVar.SomeField
std::cout << NAMEOF_FULL(&SomeStruct::SomeMethod2) << std::endl; // &SomeStruct::SomeMethod2 std::cout << NAMEOF_FULL(&SomeStruct::SomeMethod2) << std::endl; // &SomeStruct::SomeMethod2
} }
@ -110,7 +102,7 @@ void TestCase2() {
} }
void TestCase3() { 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() { int main() {

View file

@ -49,18 +49,6 @@ constexpr const char* Nameof(const char* name, const size_t length) {
#define NAMEOF_FULL(name) nameof::Nameof<decltype(name)>(NAMEOF_RAW(name), 0) #define NAMEOF_FULL(name) nameof::Nameof<decltype(name)>(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. // Used to obtain the string name of a type.
#define NAMEOF_TYPE(type) nameof::Nameof<type>(NAMEOF_RAW(type), sizeof(NAMEOF_RAW(type)) / sizeof(char) - 1) #define NAMEOF_TYPE(type) nameof::Nameof<type>(NAMEOF_RAW(type), sizeof(NAMEOF_RAW(type)) / sizeof(char) - 1)

View file

@ -86,15 +86,15 @@ TEST_CASE("NAMEOF") {
} }
SECTION("NAMEOF_VARIABLE") { SECTION("NAMEOF_VARIABLE") {
REQUIRE(std::strcmp(NAMEOF_VARIABLE(someVar.SomeField), "SomeField") == 0); REQUIRE(std::strcmp(NAMEOF(someVar.SomeField), "SomeField") == 0);
REQUIRE(std::strcmp(NAMEOF_VARIABLE((&someVar)->SomeField), "SomeField") == 0); REQUIRE(std::strcmp(NAMEOF((&someVar)->SomeField), "SomeField") == 0);
REQUIRE(std::strcmp(NAMEOF_VARIABLE(::someVar), "someVar") == 0); REQUIRE(std::strcmp(NAMEOF(::someVar), "someVar") == 0);
} }
SECTION("NAMEOF_FUNCTION") { SECTION("NAMEOF_FUNCTION") {
REQUIRE(std::strcmp(NAMEOF_FUNCTION(someVar.SomeMethod1()), "SomeMethod1()") == 0); REQUIRE(std::strcmp(NAMEOF(someVar.SomeMethod1()), "SomeMethod1()") == 0);
REQUIRE(std::strcmp(NAMEOF_FUNCTION(&SomeStruct::SomeMethod2), "SomeMethod2") == 0); REQUIRE(std::strcmp(NAMEOF(&SomeStruct::SomeMethod2), "SomeMethod2") == 0);
REQUIRE(std::strcmp(NAMEOF_FUNCTION(SomeMethod3), "SomeMethod3") == 0); REQUIRE(std::strcmp(NAMEOF(SomeMethod3), "SomeMethod3") == 0);
} }
} }
@ -135,15 +135,15 @@ TEST_CASE("NAMEOF_FULL") {
} }
SECTION("NAMEOF_VARIABLE_FULL") { SECTION("NAMEOF_VARIABLE_FULL") {
REQUIRE(std::strcmp(NAMEOF_VARIABLE_FULL(someVar.SomeField), "someVar.SomeField") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(someVar.SomeField), "someVar.SomeField") == 0);
REQUIRE(std::strcmp(NAMEOF_VARIABLE_FULL((&someVar)->SomeField), "(&someVar)->SomeField") == 0); REQUIRE(std::strcmp(NAMEOF_FULL((&someVar)->SomeField), "(&someVar)->SomeField") == 0);
REQUIRE(std::strcmp(NAMEOF_VARIABLE_FULL(::someVar), "::someVar") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(::someVar), "::someVar") == 0);
} }
SECTION("NAMEOF_FUNCTION_FULL") { SECTION("NAMEOF_FUNCTION_FULL") {
REQUIRE(std::strcmp(NAMEOF_FUNCTION_FULL(someVar.SomeMethod1()), "someVar.SomeMethod1()") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(someVar.SomeMethod1()), "someVar.SomeMethod1()") == 0);
REQUIRE(std::strcmp(NAMEOF_FUNCTION_FULL(&SomeStruct::SomeMethod2), "&SomeStruct::SomeMethod2") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(&SomeStruct::SomeMethod2), "&SomeStruct::SomeMethod2") == 0);
REQUIRE(std::strcmp(NAMEOF_FUNCTION_FULL(SomeMethod3), "SomeMethod3") == 0); REQUIRE(std::strcmp(NAMEOF_FULL(SomeMethod3), "SomeMethod3") == 0);
} }
} }