Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Yao Qi <qiyaoltc@gmail.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Add DISABLE_COPY_AND_ASSIGN
Date: Tue, 18 Jul 2017 15:13:00 -0000	[thread overview]
Message-ID: <86iniprd5l.fsf@gmail.com> (raw)
In-Reply-To: <179e2d35-d903-1d6d-256a-063a35d677d2@redhat.com> (Pedro Alves's	message of "Tue, 18 Jul 2017 15:22:17 +0100")

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.

>>  /* 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.  */

#if __cplusplus >= 201103
#define DISABLE_COPY_AND_ASSIGN(TYPE)		\
  TYPE (const TYPE&) = delete;			\
  void operator= (const TYPE &) = delete;
#else
#define DISABLE_COPY_AND_ASSIGN(TYPE)		\
  TYPE (const TYPE&);				\
  void operator= (const TYPE &);
#endif /* __cplusplus >= 201103 */

>> --- a/gdb/common/refcounted-object.h
>> +++ b/gdb/common/refcounted-object.h
>> @@ -19,6 +19,8 @@
>>  #ifndef REFCOUNTED_OBJECT_H
>>  #define REFCOUNTED_OBJECT_H
>>  
>> +#include "common-defs.h"
>> +
>
> This should not be necessary (and is against the guidelines [1]),
> since .c files must include defs.h/common-defs.h first thing.  Why did
> you need it?
>
> [1]
> https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Include_Files

OK, good to know this link.  Fixed.

-- 
Yao (齐尧)


  reply	other threads:[~2017-07-18 15:13 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 [this message]
2017-07-18 15:38     ` Pedro Alves
2017-09-09 18:45       ` Simon Marchi
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=86iniprd5l.fsf@gmail.com \
    --to=qiyaoltc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.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