mardi 24 octobre 2017

std::vector seems to prefer copy over move construction when auto-resizing

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:

Aucun commentaire:

Enregistrer un commentaire