How is std::vector::swap implemented?
问题 It occurred to me that the fastest way to copy the array from one std::vector to another would be to swap their pointers, as long as you don't care anymore about the vector you are swapping from. So I went looking and found std::vector::swap . I assume that swapping pointers is how its implemented, but I didn't see an explanation in the reference. 回答1: A simplified, minimal vector implementation might have something like the following members to manage the data in the vector: template