mardi 29 mars 2016

How to determine programmatically if an expression is rvalue or lvalue in C++?

What's the best way to determine if an expression is a rvalue or lvalue in C++? Probably, this is not useful in practice but since I am learning rvalues and lvalues I thought it would be nice to have a function is_lvalue which returns true if the expression passed in input is a lvalue and false otherwise.

Example:

std::string a("Hello");
is_lvalue(str::string()); // false
is_lvalue(a); // true  

Aucun commentaire:

Enregistrer un commentaire