[cfe-dev] deprecating copy construction and assignment

Jonathan Sauer jonathan.sauer at gmx.de
Thu Mar 29 07:31:47 PDT 2012


Hello,

> One needs to be more careful with defaulting the move members.  It is easy to default them and have them get implicitly deleted:
> 
> struct member
> {
>    member();
>    member(const member&);
>    member& operator=(const member&);
>    ~member();
> };
> 
> struct A
> {
>    member m_;
> 
>    A() = default;
>    A(const A&) = default;
>    A& operator=(const A&) = default;
>    A(A&&) = default;
>    A& operator=(A&&) = default;
>    ~A() = default;
> };
> 
> A is neither move constructible nor move assignable.  The following is probably what was intended:

I suggest enhancing the error message with an explanation: "A is not move assignable because member 'm_'
has an {explicitly|implicitly} deleted move assignment operator." Or even "... has a move assignment
operator that was implicitly deleted by the explicit copy assignment operator".


Jonathan





More information about the cfe-dev mailing list