Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Pedro Alves <palves@redhat.com>, Yao Qi <qiyaoltc@gmail.com>
Cc: <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Add DISABLE_COPY_AND_ASSIGN
Date: Sat, 09 Sep 2017 18:45:00 -0000	[thread overview]
Message-ID: <19cd9fec-2b41-e827-0d51-b2a1b0680808@ericsson.com> (raw)
In-Reply-To: <075e7089-199f-f251-c4a2-58099b5f06e9@redhat.com>

On 2017-07-18 05:38 PM, Pedro Alves wrote:
> 
> On 07/18/2017 04:13 PM, Yao Qi wrote:
>> Pedro Alves <palves@redhat.com> writes:
>>
>>> Yes, please.  I've been meaning to add something like this for a while.
>>>
>>> IMO, this could go in include/ansidecl.h, with a fallback version for
>>> #if __cplusplus < C++11 that declares the methods without =delete (you
>>> get a link error instead).
>>>
>>
>> I thought about adding this into include/, but can't find the right
>> file.  I'll move the macro to include/ansidecl.h.
> 
> Thanks.  Note that that file is maintained by gcc.
> 
>>
>>>>  /* Pull in gdb::unique_xmalloc_ptr.  */
>>>>  #include "common/gdb_unique_ptr.h"
>>>>  
>>>> +#define DISABLE_COPY_AND_ASSIGN(TYPE)		\
>>>> +  TYPE (const TYPE&) = delete;			\
>>>> +  void operator= (const TYPE &) = delete;
>>>> +
>>>
>>> Should this have an intro comment?
>>>
>>
>> I thought it is too simple to have a comment :)  How about this?
>>
>> /* A macro to disable the copy constructor and assignment operator.
>>    When building with C++ 11, explicitly delete these methods.
>>    Otherwise, place this macro in the private: declarations of a class.  */
> 
> How about this tweak:
> 
>  /* A macro to disable the copy constructor and assignment operator.
>     When building with C++11 and above, the methods are explicitly
>     deleted, causing a compile-time error if something tries to copy.
>     For C++03, this just declares the methods, causing a link-time
>     error if the methods end up called (assuming you don't
>     define them).  For C++03, for best results, place the macro
>     under the private: access specifier, so that most attempts at
>     copy are caught at compile-time.  */
> 
> Thanks,
> Pedro Alves
> 

Hi Yao,

Out of curiosity, did you make any progress on this?

Thanks,

Simon


  reply	other threads:[~2017-09-09 18:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 13:48 Yao Qi
2017-07-18 14:22 ` Pedro Alves
2017-07-18 15:13   ` Yao Qi
2017-07-18 15:38     ` Pedro Alves
2017-09-09 18:45       ` Simon Marchi [this message]
2017-09-15 12:05         ` Yao Qi
2017-09-19  9:13 ` Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19cd9fec-2b41-e827-0d51-b2a1b0680808@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=qiyaoltc@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox