LearnFrenzy
Sign in Take a free test

Move Semantics · Move Semantics MCQ · Question 9

Why does vector care about noexcept moves? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links