Multiple ChoiceBeginner 45s
Returning a named local and NRVO
A function returns a named local `T obj; return obj;` where T has both copy and move constructors. In C++17, what typically happens?
Options
- 1The copy constructor is always invoked because `obj` is a named lvalue.
- 2NRVO may elide the copy entirely; if not elided, `obj` is treated as an rvalue and move-constructed.
- 3A compile error occurs: you must write `return std::move(obj);`.
- 4The move constructor is always invoked; elision is not permitted for named locals.
Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.