From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id A246E3858C50 for ; Tue, 12 Jul 2022 13:45:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A246E3858C50 Received: by mail-ed1-x533.google.com with SMTP id v12so10142660edc.10 for ; Tue, 12 Jul 2022 06:45:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Wgvm2MXuA6I8FERCYMJFjD/Rix5EaFoYBGwdbd4DVyE=; b=F1HSX9m5OPEGD8NflZu+1GKowHj1XZoBDm9LguACiqwqV8Xhy7VoSNoz/WdklduAO7 zxTZ1wTGZ0z7fdQKPWY1u9HWAqeJI8g4KMviJHkWVMZztzE7MFaj9ZcfqJFUUzYaUj1S IxKyPLB7qebYSeWjXuWa+3Y8L7okm/HZlzta8tMiZsb+dy+HwRWO1iWDAXhQJ9g9w0Eu q6VOaT5QVOFF62FLQgPk5XS88So+RkTP1kTOrdTFp/0q4gooE1a6zwuw3CAZa0wrhd/U RKW2ZBjrXDi4fo/tgXBpyQgcY4vfezrWd0qirq5hZpeTXNp7I1YLWHkp02/Q2T5Aywy3 kZ6w== X-Gm-Message-State: AJIora/WqAPft65ISMEuc3Ry8MX40YL/TnI3ofpaBxTS6Yz1dgMt20fm KkrZsOW/pxTzTXZNyt5eON/7iAG57bfWuOeaN5c= X-Google-Smtp-Source: AGRyM1s8toBwUMmGPvoA2tMLzMy2kY9MBIkwpf2rfFXXQQcN15duBdXobgf5wQGD2VjM3ZpRi6WCebzantWak0g+aHk= X-Received: by 2002:a05:6402:254c:b0:43a:9e77:3b29 with SMTP id l12-20020a056402254c00b0043a9e773b29mr31726173edb.356.1657633516446; Tue, 12 Jul 2022 06:45:16 -0700 (PDT) MIME-Version: 1.0 References: <20220712002527.417444-1-dmalcolm@redhat.com> <03b8afc0-b917-e940-4995-9ba5493567c2@palves.net> In-Reply-To: <03b8afc0-b917-e940-4995-9ba5493567c2@palves.net> From: Jonathan Wakely Date: Tue, 12 Jul 2022 14:45:04 +0100 Message-ID: Subject: Re: [PATCH 1/2] Add gcc/make-unique.h To: Pedro Alves Cc: David Malcolm , gcc-patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2022 13:45:19 -0000 On Tue, 12 Jul 2022 at 14:24, Pedro Alves wrote: > > On 2022-07-12 1:25 a.m., David Malcolm via Gcc-patches wrote: > > > I tried adding it to gcc/system.h, but anything that uses it needs to > > have std::unique_ptr declared, which meant forcibly including > > from gcc/system.h > > Did you consider making gcc/system.h include gcc/make-unique.h itself > if INCLUDE_MEMORY is defined? Something like: > > #ifdef INCLUDE_MEMORY > # include > + #include "make-unique.h" > #endif > > This is because std::make_unique is defined in in C++14. This would > mean fewer changes once GCC requires C++14 (or later) and this new header is eliminated. That's a good idea. > > (in the root namespace, rather than std::, which saves a bit more typing). > > It's less typing now, but it will be more churn once GCC requires C++14 (or later), at > which point you'll naturally want to get rid of the custom make_unique. More churn > since make_unique -> std::make_unique may require re-indentation of arguments, etc. > For that reason, I would suggest instead to put the function (and any other straight > standard library backport) in a 3-letter namespace already, like, gcc::make_unique > or gnu::make_unique. That way, when the time comes that GCC requires C++14, > the patch to replace gcc::make_unique won't have to worry about reindenting code, > it'll just replace gcc -> std. Or (when the time comes) don't change gcc->std and do: namespace gcc { using std::make_unique; } or just leave it in the global namespace as in your current patch, and at a later date add a using-declaration to the global namespace: using std::make_unique;