
17 Aug
2009
17 Aug
'09
3:56 p.m.
Thomas Klimpel escribió:
But I have a question about Boost.Move: Because the problem Boost.Move addresses is so important, and Boost.Move wasn't around, my existent code uses efficient implementations of "swap" as a substitute. The documentation shows that Boost.Move can be used to implement an efficient swap. But what about the other direction? Can Boost.Move exploit an existent efficient swap?
Boost.Move calls user defined constructors to operate, so you can implement your move constructors using your efficient swap: Type(BOOST_RV_REV(Type) t) : ...() //Empty construction { this->swap(t); } Ditto for move assignment: Type & operator=(BOOST_RV_REV(Type) t) { Type tmp(boost::move(t)); this->swap(tmp); } Best, Ion