Topic: c++0x: Compiler-generated move constructor?


Author: german diago <germandiago@gmail.com>
Date: Sat, 24 Jan 2009 18:13:34 CST
Raw View
Hello. I would like to know if the compiler will generate move
constructors, as it does with copy constructors, because it can be
implemented as a move of each of the parts of an object.
I've realized looking at the documentation for the standard that
CopyAssignable is a refinement of MoveAssignable.
So I tried in conceptgcc not to define move constructor and it works.
Is this correct.

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: Sean Hunt <rideau3@gmail.com>
Date: Sun, 25 Jan 2009 03:19:18 CST
Raw View
On Jan 24, 5:13 pm, german diago <germandi...@gmail.com> wrote:
> Hello. I would like to know if the compiler will generate move
> constructors, as it does with copy constructors, because it can be
> implemented as a move of each of the parts of an object.
> I've realized looking at the documentation for the standard that
> CopyAssignable is a refinement of MoveAssignable.
> So I tried in conceptgcc not to define move constructor and it works.
> Is this correct.

There was one proposal to allow the explicit addition of default move
constructors, move assignment operators, and swap functions with the =
default syntax. No proposal has been made to add these functions
implicitly, for reasons of backwards-compatibility.

As for the concepts, any object that can be assigned from a rvalue of
class type (including any with an assignment operator taking const T&,
which is declared implicitly) will meet the requirements for
MoveAssignable. By removing just the move assignment operator, you
have probably left the copy assignment operator there, fulfilling the
concept.

I hope this helps.

Sean


--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]