From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id E40223858D37 for ; Tue, 23 Aug 2022 14:53:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E40223858D37 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-507-8JfAjVAzP-6346gWJb5-aQ-1; Tue, 23 Aug 2022 10:53:13 -0400 X-MC-Unique: 8JfAjVAzP-6346gWJb5-aQ-1 Received: by mail-qt1-f200.google.com with SMTP id e30-20020ac8011e000000b00342f61e67aeso10696016qtg.3 for ; Tue, 23 Aug 2022 07:53:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=RWkPBxQ8UkTbPv23neE4OkSMnjBhQTEqZJyh0eUzvII=; b=kF4lp8lKWOto/79j/eCJUzrdEHXorbZIocaKx4ezv59z8tARkXzH13Nk9916b/nl9K y4tbLQI8HTgi/oiKKtZNX6MgKuQAUNjaP+SP7n5Kf30Y4MewwJsyNSiVKoR/m7rDDSGh me6Kph8kcFxmZ+heqCNZLNsl/6rdyvtzMLAL7xLDivfPxIfcjhQnHQ0gUNfUdK1b3esv Sit2LCc1ZfsKQT2v8wsay2b7iwSa3Hn44Yeq3Sj2tKt5wUFirGTlxxN4k4qoOl14y2/r RWLjO4t01wafaApV3TuN13WzaH339Bv27Fx99wlLYAGNTKXJKyrG7KFQI9rIV1fLPkWP fUcw== X-Gm-Message-State: ACgBeo3qSAlkNm+XM4qTvjqYjuV+/WCFSnj7Q+aQp32wIg10yVpBEqz3 mIXrMelmNtawdl6SKIQmCClGAwFbc9ItWsu07iXaH/7Te+aFoAe/Ovttme056jw1uZtImUb6Oxr CJfEx8Y8N7vOL3IjEVPWoUs2uZfFnAkg= X-Received: by 2002:a37:4452:0:b0:6bb:fb52:5c75 with SMTP id r79-20020a374452000000b006bbfb525c75mr9173405qka.638.1661266392918; Tue, 23 Aug 2022 07:53:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR74v6BYjOtV5+nRK9hlYAWssxWi8KLotLlw6jcHJ/akNHpalo98flQyGj6zHSxnVXn0DGRR6BRo1gWTvgFuZVw= X-Received: by 2002:a37:4452:0:b0:6bb:fb52:5c75 with SMTP id r79-20020a374452000000b006bbfb525c75mr9173389qka.638.1661266392726; Tue, 23 Aug 2022 07:53:12 -0700 (PDT) MIME-Version: 1.0 References: <20220823013500.1756466-1-ppalka@redhat.com> <6f6c8fa3-26b0-cf5f-0926-7c2dab46b63a@idea> In-Reply-To: <6f6c8fa3-26b0-cf5f-0926-7c2dab46b63a@idea> From: Jonathan Wakely Date: Tue, 23 Aug 2022 15:53:02 +0100 Message-ID: Subject: Re: [PATCH 1/3] libstdc++: Separate construct/convertibility tests for std::tuple To: Patrick Palka Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Aug 2022 14:53:16 -0000 On Tue, 23 Aug 2022 at 14:44, Patrick Palka wrote: > > On Tue, 23 Aug 2022, Jonathan Wakely wrote: > > > On Tue, 23 Aug 2022 at 02:35, Patrick Palka via Libstdc++ > > wrote: > > > > > > P2321R2 adds new conditionally explicit constructors to std::tuple which > > > we'll concisely implement in a subsequent patch using explicit(bool), like > > > in our C++20 std::pair implementation. But before we can do that, this > > > patch first adds members to _TupleConstraints that test for constructibility > > > and convertibility separately; we'll use the first in the new constructors' > > > constraints, and the second in their explicit specifier. > > > > > > In passing, this patch also redefines the existing predicates > > > __is_ex/implicitly_constructible in terms of these new members. This > > > seems to reduce compile time and memory usage by about 10% for large > > > > Nice. > > > > > tuples when using the relevant constructors constrained by > > > _Explicit/_ImplicitCtor (since we no longer have to redundantly expand > > > and process is_constructible<_Types, _UTypes>... twice for each pair of > > > such constructors). In order to retain maximal short circuiting, do > > > this only when constexpr if is available. > > > > Would we get similar benefits for C++11 and C++14 by doing: > > > > return __and_<__and_...>, > > __and_...> > > >::value; > > > > This is slightly more work in total, but if we have __and_ and > > __and_> then the A and B instantiations will be cached and > > can be reused. > > Good idea, it seems we get pretty much the same 10% improvement for > C++11/14 with this approach. I reckon we might as well then define > __convertible and __constructible as alias templates instead of as > variable templates and use them unconditionally in > __is_im/explicitly_constructible for benefit of all language versions. I had a similar thought after hitting send. > Using constexpr if instead of the outer __and_ seems to yield a marginal > improvement at best and __and_v is currently just __and_::value, so it > doesn't seem worth it to have different definitions for C++17 at least > for now. > > What do you think about the following? OK for trunk - thanks.