Is an expression including a function type lvalue or rvalue?

void fn() {}
void (&lref)() = fn;
void (&&rref)() = fn;

int main() {}

It compiles well under g ++ 4.8.1.

So, it fnis an expression, and the expression must have a category in accordance with the ISO standard.

What category does the expression belong to before automatic type promotion is performed (since both links can accept the result of evaluating the expression fn)?

+4
source share
1 answer

Per C ++ 11 3.10 / 1, a function is always an lvalue. So the expression fnis an lvalue.

8.5.3/5, rvalue:

  • lvalue const- (.. cv1 const), rvalue.

      • - xvalue, prvalue, prvalue lvalue "cv1 T1" "cv2 T2",
      • ...

      ...

(, )

+4

All Articles