← 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?
- A.noexcept makes them run on a separate thread
- B.The compiler rejects move constructors without it
- C.vector uses a move constructor when it grows only if it cannot throw; otherwise it copies
- 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 →