scdmb
scdmb

Reputation: 15611

Can an array or function lvalue be converted to an rvalue?

According to C++ Standard 2003:

An lvalue (3.10) of a non-function, non-array type T can be converted to an rvalue.

What does it mean that array and function cannot be converted to rvalue?

Upvotes: 3

Views: 166

Answers (1)

Cat Plus Plus
Cat Plus Plus

Reputation: 129754

Both function and array types are covered by later clauses (4.2, 4.3).

An lvalue or rvalue of type “array of N T” or “array of unknown bound of T” can be converted to an rvalue of type “pointer to T.” The result is a pointer to the first element of the array.

(...)

An lvalue of function type T can be converted to an rvalue of type “pointer to T.” The result is a pointer to the function.

Upvotes: 6

Related Questions