Question 16
Back to Exercise
Why is std::forward<T>(arg) used inside a function taking T&& arg?
- A To make a copy
- B To pass arg on with its original value category – rvalues as rvalues, lvalues as lvalues Correct
- C To convert arg to a pointer
- D To check arg for null
Correct Answer: Option B
Without it the named parameter is always an lvalue, so temporaries would be copied instead of moved.
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!