nameof_module/nameof.cpp

13 lines
295 B
C++
Raw Normal View History

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>
2016-10-09 14:44:36 +00:00
const char* template_nameof(const T& validate_type, const char* name)
2016-10-05 09:14:37 +00:00
{
return name;
}
// int test = 0;
// std::cout << nameof(test) << std::endl;
2016-10-05 09:16:29 +00:00
// prints "test”