
Andrea Torsello <torsello@dsi.unive.it> writes:
David Abrahams wrote:
My library is not relying on it being enough. It's just turning off the mechanisms needed for non-RVO'ing compilers where appropriate.
This is clearly the best thing, which leaves us where we do not provide any X(X const &) constructor (explicit or implicit) unless the compiler requires it.
Uh, no: when turning off the mechanisms needed for non-RVO'ing compilers we supply a non-explicit X(X const&) ctor, and no X(X&) ctor.
You still need to convert to temporary in initializer lists, since you cannot use the assigment constructor there, but most likely you would have to do it anyway. [...]
That's what the explicit "move(x)" function is for:
exactly, my point was that in initialization lists you probably need to convert to temporary with the move(x) function. By "convert to temporary" I meant the X::temporary type I had in my examples. The move_from<X> type in your code.
Right... but that "conversion to temporary" is not the same as *actually* converting to a C++ temporary, which involves making a copy.
Considering that most/all of my ctors' logic is in the initializer list and that the two ctors' initializers will be different, I like having a way to make them the same.
[...]
Yes users would still have to provide the initializer lists.
Only one initializer list need be provided, using implicit_cast<> if neccessary.
With complicated initializer lists, I agree that one doesn't want to duplicate the list. I guess that this is a personal coding-style issue.
Yes. And you can take either approach with both technique 1 and technique 2. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com