🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Move Semantics and rvalue References: all 10 questions

Quiz: Move Semantics and rvalue References · Question 5 of 10

Why should move constructors be marked noexcept?

Why should move constructors be marked noexcept?

  1. A.noexcept makes them run on a separate thread
  2. B.The compiler rejects move constructors without it
  3. C.vector uses a move constructor when it grows only if it cannot throw; otherwise it copies
  4. D.It makes the moved-from object keep its value
Answer & explanation

Correct answer: vector uses a move constructor when it grows only if it cannot throw; otherwise it copies

Containers need a strong guarantee during regrowth, so they only trust non-throwing moves.

Can you get the rest right without peeking?

Take the timed Quiz: Move Semantics and rvalue References quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →