sumit kumar
sumit kumar

Reputation: 15

How does static_cast<type&&>(x) convert l valued r-value reference to x value type what is the internal logic?

I read std::move() does the same thing*

Upvotes: 0

Views: 242

Answers (1)

Igor Tandetnik
Igor Tandetnik

Reputation: 52591

[expr.static.cast]/1 The result of the expression static_cast<T>(v) is the result of converting the expression v to type T. If T is an lvalue reference type or an rvalue reference to function type, the result is an lvalue; if T is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue.

Emphasis mine. Therefore, static_cast<type&&>(x), where type is an object type (as opposed to a function type), is an xvalue by definition.

Upvotes: 1

Related Questions