From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 66847 invoked by alias); 18 Jul 2017 15:13:53 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 66781 invoked by uid 89); 18 Jul 2017 15:13:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:sk:static. X-HELO: mail-it0-f45.google.com Received: from mail-it0-f45.google.com (HELO mail-it0-f45.google.com) (209.85.214.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Jul 2017 15:13:48 +0000 Received: by mail-it0-f45.google.com with SMTP id v127so5252957itd.0 for ; Tue, 18 Jul 2017 08:13:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=dGuKlZqGDu/QuKCMUJg8tktnfBmQlqfgHNfBlkc2DoM=; b=mtzi2jZegEr+rY/1OgKp1/1N12+cOs37zcVcqVf3LwbCJoO1XbfLyCsuuoN/Xg/v0g MP65glpMuitvY6WZqs7SB1qBkFdj78gjT//gCD36kL5bTz60KV8uESLgedvqBtO3WCD8 SVSqAo1gJitOxpXVaOxjS1/bu328jFFFtQ3frbJCSQvapJHR3GIhiguEAbROH++nJZYa blHwLor22LvHJkjhZpUH0RRzMMXkw04FAFLXYOZicb/LsTzkCsae0+GchbrfitmilCxS Pa9id6YLj6U2FoFXG364UZqqdA1Iu0DdoGw5EYK74zGNTOt7AV9bjCQ77YyvIy3Rf8H4 XQnQ== X-Gm-Message-State: AIVw111LNyXfQx2n0moZXGfkbbNrjUnXfLZQio2TCk3L6BF4B64d5rAq wfEWSuypxv5I+5gi X-Received: by 10.36.130.68 with SMTP id t65mr3039038itd.56.1500390826028; Tue, 18 Jul 2017 08:13:46 -0700 (PDT) Received: from E107787-LIN (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id l184sm1307443iol.43.2017.07.18.08.13.44 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 18 Jul 2017 08:13:45 -0700 (PDT) From: Yao Qi To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Add DISABLE_COPY_AND_ASSIGN References: <1500385686-19857-1-git-send-email-yao.qi@linaro.org> <179e2d35-d903-1d6d-256a-063a35d677d2@redhat.com> Date: Tue, 18 Jul 2017 15:13:00 -0000 In-Reply-To: <179e2d35-d903-1d6d-256a-063a35d677d2@redhat.com> (Pedro Alves's message of "Tue, 18 Jul 2017 15:22:17 +0100") Message-ID: <86iniprd5l.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00256.txt.bz2 Pedro Alves 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 =3Ddelete (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" >>=20=20 >> +#define DISABLE_COPY_AND_ASSIGN(TYPE) \ >> + TYPE (const TYPE&) =3D delete; \ >> + void operator=3D (const TYPE &) =3D 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 >=3D 201103 #define DISABLE_COPY_AND_ASSIGN(TYPE) \ TYPE (const TYPE&) =3D delete; \ void operator=3D (const TYPE &) =3D delete; #else #define DISABLE_COPY_AND_ASSIGN(TYPE) \ TYPE (const TYPE&); \ void operator=3D (const TYPE &); #endif /* __cplusplus >=3D 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 >>=20=20 >> +#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#Includ= e_Files OK, good to know this link. Fixed. --=20 Yao (=E9=BD=90=E5=B0=A7)