Reputation: 5019
Rvalue reference is one of the best feature in c++11, but our old compilers do not support this beautiful creature. After some study, creating a moveable "unique_ptr" is not too hard with the help of boost::move, the better news is that boost::container can work with boost::move too.
My question is, is it possible to make the algorithms like std::swap_range or std::sort benefit from boost::move? Or do I have to write one for my self?
Upvotes: 3
Views: 256
Reputation: 210643
in pre-C++11 std::sort
uses swap
internally, so as long as you define swap
appropriately for your class (don't forget ADL), it should use that instead of copying each object.
Move semantics wouldn't do anything significant here.
Upvotes: 3