std::swap()
is used by many std containers (such as std::list
and std::vector
) during sorting and even assignment.
But the std implementation of swap()
is very generalized and rather inefficient for custom types.
Thus efficiency can be gained by overloading std::swap()
with a custom type specific implementation. But how can you implement it so it will be used by the std containers?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…