This commit is contained in:
Terik23 2018-03-17 08:06:04 +05:00 committed by GitHub
parent 3192011520
commit 6ae0ee00a7

View file

@ -6,6 +6,10 @@ template <typename T> const char* template_nameof_variable(const T& validate_typ
#define nameof_type(name) template_nameof_type<name>(#name)
template <typename T> const char* template_nameof_type(const char* name) { return name; }
///Used to obtain the string name of a function.
#define nameof_function(name) template_nameof_function(#name, sizeof(#name)/sizeof(char) - 1); (name);
const char* template_nameof_function(const char* name) { return name; }
//example
int test = 0;
std::cout << nameof_variable(test) << " " << nameof_type(int) << std::endl;