malcolm.parsons added a comment.

In https://reviews.llvm.org/D30610#934617, @aaron.ballman wrote:

> In https://reviews.llvm.org/D30610#934452, @malcolm.parsons wrote:
>
> > I'd like an `AllowDeletedCopyFunctions` option that allows move and 
> > destructor functions to be missing when copying is disabled.
> >
> >   struct A {
> >     A(const A&) = delete;
> >     A& operator=(const A&) = delete;
> >   }
> >   
>
>
> Doesn't `AllowMissingMoveFunctions` do almost that? If not, it should -- that 
> code produces a class that does not declare a move constructor or move 
> assignment operator per [class.copy]p8 and [class.copy.assign]p4, so that 
> would be a "missing move function". Granted, that doesn't handle the dtor 
> case, but I think an `AllowMissingDestructor` option might be overkill -- the 
> destructor isn't missing, it's implicitly declared as defaulted in that case, 
> but if the C++ Core Guidelines folks want it spelled out explicitly then, it 
> might be worth the option. Have they weighed in on your exception?


The check is about providing a consistent set of special member functions.
If you've written a destructor then you probably need to write copy functions 
to avoid double free.
If you've defaulted the destructor, as often needed in a base class, then the 
default copy functions are still valid, so `AllowSoleDefaultDtor` makes sense.
If you've written your own copy functions then you probably want to write your 
own move functions to allow moving, so `AllowMissingMoveFunctions` doesn't make 
sense.
If you've deleted the copy functions, then you probably don't want the move 
functions either, so `AllowDeletedCopyFunctions` would make sense.

I haven't asked the Core Guidelines folks.


https://reviews.llvm.org/D30610



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to