[move][container] Fast-track reviews for Move and Container?

Hi, As some others have mentioned, I'd like to ask if Boost.Move and Boost.Container could meet the requirements for a Fast Track review (the Review Wizard has the last word according to the Boost Formal Process, but I'll like to see if there is consensus). Arguments: Boost.Move -> Only one header (move.hpp) -> Technique already in use in Boost (in several detail namespaces). This is a proposal for a common implementation. -> Boost-conformant implementation available in sandbox. Boost.Container -> Most of them standard containers -> Node containers are just wrappers over Boost.Intrusive -> Most containers (all except stable_vector) were already reviewed for Boost.Interprocess. -> Boost-conformant implementation available in sandbox. I'll be specially interested in pushing Move first, so that we could have move semantics for Boost 1.41. Best, Ion

Ion Gaztañaga wrote:
Hi,
As some others have mentioned, I'd like to ask if Boost.Move and Boost.Container could meet the requirements for a Fast Track review (the Review Wizard has the last word according to the Boost Formal Process, but I'll like to see if there is consensus). Arguments:
Boost.Move
-> Only one header (move.hpp) -> Technique already in use in Boost (in several detail namespaces). This is a proposal for a common implementation. -> Boost-conformant implementation available in sandbox.
Boost.Container
-> Most of them standard containers -> Node containers are just wrappers over Boost.Intrusive -> Most containers (all except stable_vector) were already reviewed for Boost.Interprocess. -> Boost-conformant implementation available in sandbox.
I'll be specially interested in pushing Move first, so that we could have move semantics for Boost 1.41.
Best,
Ion _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
+1 for a Fast Track review. IMO it will be better to do them separately. Best, Vicente -- View this message in context: http://www.nabble.com/-move--container--Fast-track-reviews-for-Move-and-Cont... Sent from the Boost - Dev mailing list archive at Nabble.com.

Ion Gaztañaga wrote:
As some others have mentioned, I'd like to ask if Boost.Move and Boost.Container could meet the requirements for a Fast Track review (the Review Wizard has the last word according to the Boost Formal Process, but I'll like to see if there is consensus). Arguments:
Boost.Move
-> Only one header (move.hpp) -> Technique already in use in Boost (in several detail namespaces). This is a proposal for a common implementation. -> Boost-conformant implementation available in sandbox.
...
I'll be specially interested in pushing Move first, so that we could have move semantics for Boost 1.41.
+9 for this. 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? Regards, Thomas

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

Ion Gaztañaga wrote:
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); }
I hope I can omit the empty construction, since some of my classes have many member variables. But on second thought, I should at least initialize the pointers to zero, to avoid undefined behavior in the destructor.
Ditto for move assignment:
Type & operator=(BOOST_RV_REV(Type) t) { Type tmp(boost::move(t)); this->swap(tmp); }
I hope I can omit the temporary, because two calls to swap are less efficient than a single call to swap. I can't find any second thought that forces me to create a temporary. Do I miss something? Regards, Thomas

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 17 August 2009, Thomas Klimpel wrote:
Type & operator=(BOOST_RV_REV(Type) t) { Type tmp(boost::move(t)); this->swap(tmp); }
I hope I can omit the temporary, because two calls to swap are less efficient than a single call to swap. I can't find any second thought that forces me to create a temporary. Do I miss something?
I don't think you need to. The temporary is useful if you want to always give moved-from objects a specific state (presumably the move constructor does this). But the standard is looser, it only requires the moved-from object doesn't violate any of the class invariants. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkqJurkACgkQ5vihyNWuA4UPdwCcDx1z5q4kVkqgF6wcUNMQItqa N+AAn28ftrbGEi8hohQRJGSl+WdIYx7M =swov -----END PGP SIGNATURE-----

Thomas Klimpel escribió:
Type(BOOST_RV_REV(Type) t) : ...() //Empty construction { this->swap(t); }
I hope I can omit the empty construction, since some of my classes have many member variables. But on second thought, I should at least initialize the pointers to zero, to avoid undefined behavior in the destructor.
This is a generic move constructor, if Type has a trivial destructor there is no need to mark the type as "moved", but as you say, if you have some pointers, you should prepare the swapped class destructor to avoid undefined behaviour.
Ditto for move assignment:
Type & operator=(BOOST_RV_REV(Type) t) { Type tmp(boost::move(t)); this->swap(tmp); }
I hope I can omit the temporary, because two calls to swap are less efficient than a single call to swap. I can't find any second thought that forces me to create a temporary. Do I miss something?
There is no reason if you know your type and you can put t in a destructible state. This is just a generic ("safe"?) move assignment operator. You could do: Type & operator=(BOOST_RV_REV(Type) t) { this->swap(t); } if semantically is ok for your Type. For some types (shared_ptr, containers...) a simple swap can lead to unexpected behavior because the programmer might not expect any value transference: shared_ptr<X> a(...), b(..); //Should b take ownership of a's resources? //That might be quite surprising. a = boost::move(b); Best, Ion
participants (4)
-
Frank Mori Hess
-
Ion Gaztañaga
-
Thomas Klimpel
-
Vicente Botet Escriba