Question 19
Back to Exercise
In C++17, what happens with T make() { return T(42); } and T t = make();?
- A Two copies are made
- B T is constructed directly in t – no copy or move constructor is called Correct
- C One move is always made
- D It depends on optimization level
Correct Answer: Option B
Returning a prvalue is guaranteed to construct in place. Returning a named local (NRVO) is only permitted, not guaranteed.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!