This commit is contained in:
parent
3192011520
commit
6ae0ee00a7
1 changed files with 4 additions and 0 deletions
|
@ -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)
|
#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; }
|
||||||
|
|
||||||
|
///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
|
//example
|
||||||
int test = 0;
|
int test = 0;
|
||||||
std::cout << nameof_variable(test) << " " << nameof_type(int) << std::endl;
|
std::cout << nameof_variable(test) << " " << nameof_type(int) << std::endl;
|
||||||
|
|
Loading…
Reference in a new issue