2

It seems that when std::vector resizes itself (e.g. when inserting a new element and there not being enough room), it uses its elements' copy constructor rather than their move constructor, even if they have both.

  • Is that a general rule or do I need to do something to make sure the move ctor is preferred (e.g. mark things as noexcept?)
  • If this is the general rule - why is that the case?

Notes:

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    Possible duplicate of [How to enforce move semantics when a vector grows?](https://stackoverflow.com/questions/8001823/how-to-enforce-move-semantics-when-a-vector-grows) – einpoklum Oct 24 '17 at 18:26

0 Answers0