Clean up and add new test
This commit is contained in:
parent
b8a4091fdc
commit
efb385e901
2 changed files with 12 additions and 11 deletions
|
@ -38,6 +38,10 @@ struct Long {
|
||||||
LL LLField;
|
LL LLField;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TestRValue {
|
||||||
|
int Field;
|
||||||
|
};
|
||||||
|
|
||||||
int someVar = 0;
|
int someVar = 0;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
@ -62,9 +66,11 @@ int main() {
|
||||||
std::cout << NAMEOF_VAR(&SomeStruct::SomeMethod) << std::endl; // SomeMethod
|
std::cout << NAMEOF_VAR(&SomeStruct::SomeMethod) << std::endl; // SomeMethod
|
||||||
std::cout << NAMEOF_VAR(otherVar.LLField.LLLField) << std::endl; // LLLField
|
std::cout << NAMEOF_VAR(otherVar.LLField.LLLField) << std::endl; // LLLField
|
||||||
std::cout << NAMEOF_VAR(&someVar) << std::endl; // someVar
|
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(*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; // 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()
|
||||||
}
|
}
|
|
@ -26,16 +26,11 @@
|
||||||
|
|
||||||
inline constexpr const char* template_nameof(const char* name, const size_t length) {
|
inline constexpr const char* template_nameof(const char* name, const size_t length) {
|
||||||
return length == 0 ? name
|
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]
|
? &name[length]
|
||||||
: template_nameof(name, length - 1);
|
: template_nameof(name, length - 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue