From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) by sourceware.org (Postfix) with ESMTPS id C4C7C3858C50 for ; Tue, 12 Jul 2022 13:24:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C4C7C3858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f53.google.com with SMTP id r10so5005632wrv.4 for ; Tue, 12 Jul 2022 06:24:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9cSSp2QCmVdyCox+HYhV1fsCe4DikKslPsSoDZEgmmU=; b=yaK5KrMxLJp0RmVW5iWOZWRcVgbn1gxvRToIG6ynYc0uneKOCxuM87JZD3SDkbbXsf 61Oq1ABiMAgwzYbw2L8xIUjaVFMwBH5RUTz+UA8t9k9jfeNG4RyKt1j4S/DVhef3w6Mz ZSMSVP459ZVyYPqlcGE5f2m6+0TCmmlyg/09U5tHpBXhauRkWVwWp9lnDHiyBmB4HRp9 R6fkFVazucGE5yWwnr+pjaArYNODD5erNOHVT9dW7SS3NmYMFC8I+otuWQibw6bTfJCV /1xNFo2WaxYHrHHNyJaeRHQKdvyzU0y25h6xpKyhRL3v8TRcLSn80TXSamMX9RbaFjjJ Wfxg== X-Gm-Message-State: AJIora9xVOIUs4KjbFkkxmHDxZ3ZL2oEHztHzaqikENMMV6kZm+8T4zk fqT1AC5oQkvGaMOYaq3pTf9NuFZGd7Y= X-Google-Smtp-Source: AGRyM1sXI8W4x4mMyfZX4ASyYnXx6an6oY+NvMDAHKxiRph/pRvnjIHqBe5NTRz10WNcdS825/QPTA== X-Received: by 2002:a05:6000:1d98:b0:21b:aead:9b6c with SMTP id bk24-20020a0560001d9800b0021baead9b6cmr21807189wrb.531.1657632241739; Tue, 12 Jul 2022 06:24:01 -0700 (PDT) Received: from ?IPv6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id s7-20020a5d6a87000000b0021bbf6687b1sm10214747wru.81.2022.07.12.06.24.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jul 2022 06:24:00 -0700 (PDT) Subject: Re: [PATCH 1/2] Add gcc/make-unique.h To: David Malcolm , Jonathan Wakely , gcc-patches@gcc.gnu.org References: <20220712002527.417444-1-dmalcolm@redhat.com> From: Pedro Alves Message-ID: <03b8afc0-b917-e940-4995-9ba5493567c2@palves.net> Date: Tue, 12 Jul 2022 14:23:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20220712002527.417444-1-dmalcolm@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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:24:05 -0000 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. > (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.