According to cppreference.com a.m
is prvalue
the member of object expression, where m is a member enumerator or a non-static member function[2];
Does it mean for object expression ie a.m where m is a member of a of enumeration type, the value category of expression itself would be prvalue?
As per my following testing, it does not seem to be the case. What did I miss?
enum class Color : char {
Red = 'r'
};
struct Test {
Color c;
};
void func(Color&&) {
std::cout << "rvalue ref\n";
}
void func(Color&) {
std::cout << "lvalue ref\n";
}
int main()
{
Test t;
func(t.c);
return 0;
}
Output: lvalue ref
Aucun commentaire:
Enregistrer un commentaire