Reputation: 2793
How would you go if you had to write a proper C++ function that does the same as the operator '#' in macros?
It would be useful if it were possible to do it at runtime.
Upvotes: 0
Views: 99
Reputation: 20063
You can't. What you are basically asking for is this...
void function(int someargname)
{
std::cout << #someargname << std::endl;
}
int main()
{
function(3);
return 0;
}
And expecting to get "someargname" as the output instead of "3". The language simply does not support that syntax.
Upvotes: 4