Subject: Re: [boost] Temporary objects
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2009-10-30 19:44:35
> by the way such reasoning can really put that proposal on ice and
> we'll not see it in the new standard
> on the other hand all responsibility can be laid on users' shoulders
Well, since swap itself has the same issues, there's no reason to put the proposal on ice.
The point of the rvalue-references proposal is probably that rvalue-references are like normal references with slightly different rules which objects they can bind. This is easy for a compiler to implement and easy for a user to understand.
What I really would like for the move-proposal is to allow implementing the move-assignment operator as a simple swap, even for vector or shared_ptr. However, it won't happen. First of all, convincing everybody that it makes sense is impossible, and on top of that another language change would be required. The language change would have to say that temporary objects that bind to a non-const rvalue-reference get destroyed directly after the function/method returns (in order to avoid a counter-example that Dave proposed). This change would be difficult to implement for a compiler and difficult for a user to understand.
I guess what will happen is that most major compilers will implement rvalue-references long before they make it officially into the standard (since the standard will be ready soon, this implies that most major compilers have already implemented rvalue-references) and that the standard libraries will implement and exploit move-support at the same time. And when the next standard will be finished, it will contain rvalue-references and move-support, and it will be good enough for all practical purposes. And Scott Meyers will either have to explain how to implement a "well behaved" move-assignment operator, or explain that one has to be careful when using std::move or std::move_iterator. I guess he will have to explain both anyway :-)
I just hope that there will be some agreement on what is considered to be a "well behaved" move-assignment operator.