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:
- I'm using GCC 5.4.1 and its associated libstdc++ (but through CUDA 8.0's NVCC) with
--std=c++11
. - A Possibly related question: Vector reallocation uses copy instead of move constructor.