This commit is contained in:
parent
dd1bf76e65
commit
3192011520
1 changed files with 2 additions and 11 deletions
13
nameof.cpp
13
nameof.cpp
|
@ -1,19 +1,10 @@
|
||||||
///Used to obtain the string name of a variable.
|
///Used to obtain the string name of a variable.
|
||||||
#define nameof_variable(name) template_nameof_variable(name, #name)
|
#define nameof_variable(name) template_nameof_variable(name, #name)
|
||||||
|
template <typename T> const char* template_nameof_variable(const T& validate_type, const char* name) { return name; }
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
const char* template_nameof_variable(const T& validate_type, const char* name)
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
///Used to obtain the string name of a type.
|
///Used to obtain the string name of a type.
|
||||||
#define nameof_type(name) template_nameof_type<name>(#name)
|
#define nameof_type(name) template_nameof_type<name>(#name)
|
||||||
|
template <typename T> const char* template_nameof_type(const char* name) { return name; }
|
||||||
template <typename T>
|
|
||||||
const char* template_nameof_type(const char* name)
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
//example
|
//example
|
||||||
int test = 0;
|
int test = 0;
|
||||||
|
|
Loading…
Reference in a new issue