3 ms·
It is probably also worth noting that there is a good optimization opportunity when using noexcept move constructors. std::vector::push_back has a strong except
by alschwalm 10y ago
It is probably also worth noting that there is a good optimization opportunity when using noexcept move constructors. std::vector::push_back has a strong exception safety guarantee, so the normal behavior when the vector is at capacity is to create a new buffer and copy construct each item in the vector into it. If the copy constructor of any element throws, the original buffer is still in a coherent state.
If the type has a move constructor that is noexcept, then each element can be move-constructed without fear of an exception occurring. For many types, this is vastly more efficient.