Question 9
Back to Exercise
Why does std::vector copy elements during reallocation when their move constructor is not noexcept?
- A Copies are faster
- B If a move threw halfway, the old elements would already be damaged; copying preserves the strong exception guarantee Correct
- C noexcept is required by the compiler
- D Vectors never move
Correct Answer: Option B
It uses std::move_if_noexcept internally.
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!