Each expression in C++11 has a value category. One of lvalue, xvalue or prvalue.
Is there a way to write a macro that, given any expression as an argument, will produce a string "lvalue", "xvalue" or "prvalue" as appropriate?
For example:
int main()
{
int x;
cout << VALUE_CAT(x) << endl; // prints lvalue
cout << VALUE_CAT(move(x)) << endl; // prints xvalue
cout << VALUE_CAT(42) << endl; // prints prvalue
}
How could VALUE_CAT
be implemented?
#define VALUE_CAT(expr) get_value_description(sizeof SFINAE_test_1((expr)), sizeof SFINAE_test_2((expr)))
– Squillconstexpr
functions). (Actually I'm really glad that's not the case, would make overload resolution more convoluted than it already is!) – Chattanooga