From 9e76ea3771c02f19547873002c081d5bd3ea151b Mon Sep 17 00:00:00 2001 From: Terik23 Date: Wed, 5 Oct 2016 14:14:37 +0500 Subject: [PATCH] --- nameofcpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 nameofcpp diff --git a/nameofcpp b/nameofcpp new file mode 100644 index 0000000..8a93754 --- /dev/null +++ b/nameofcpp @@ -0,0 +1,13 @@ +///Used to obtain the string name of a variable. + +#define nameof(name) template_nameof((name), #name) + +template +const char* template_nameof(T test, const char* name) +{ + return name; +} + +// int test = 0; +// std::cout << nameof(test) << std::endl; +// prints "test” \ No newline at end of file