This commit is contained in:
commit
9e76ea3771
1 changed files with 13 additions and 0 deletions
13
nameofcpp
Normal file
13
nameofcpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
///Used to obtain the string name of a variable.
|
||||
|
||||
#define nameof(name) template_nameof((name), #name)
|
||||
|
||||
template <typename T>
|
||||
const char* template_nameof(T test, const char* name)
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
// int test = 0;
|
||||
// std::cout << nameof(test) << std::endl;
|
||||
// prints "test”
|
Loading…
Reference in a new issue