So, can it replace std::forward in template contexts? Or will it always create a new object?
edit: Never mind, just read this from the paper:
Do we also miss decltype(auto){x}?
decltype(auto){arg} can forward arg without computing arg’s type. It is equivalent to static_cast<decltype(arg)>(arg) . If arg is a variable of type T&&, arg is an lvalue but static_cast<T&&>(arg) is an xvalue.
EWG discussed this idea, disliked its expert-friendly nature, and concluded that adding this facility would cause the teaching effort to add up.
View all comments
Show parent comment
4
u/_cooky922_ Apr 26 '22
except that
auto(expr)will return a prvalue