Regarding the semantics of movement and containers:
I know that STL containers use relocation when relocation operations are defined in an element type. But how does he know if an element defined a move operation or not?
Why don't STL containers just call std :: move () on elements in any case, regardless of whether the element has defined move operations or not? I ask this because I know that you can call std :: move () on objects, even if its type does not define any move operations.
Thank.
In short, this is exactly what they do, calling std::movewithout concern, whether he can move or just copy.
std::move
, , , std::vector::resize, std::move_if_nothrow std::move.
std::vector::resize
std::move_if_nothrow