nameof_module/nameofcpp

17 lines
292 B
Text
Raw Normal View History

2016-10-05 09:15:30 +00:00
```cpp
2016-10-05 09:14:37 +00:00
///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;
2016-10-05 09:15:30 +00:00
// prints "test”
```