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.133.124]) by sourceware.org (Postfix) with ESMTPS id 6EBE43858C2A for ; Tue, 12 Sep 2023 13:15:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6EBE43858C2A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694524547; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Wh2SuiMd5ZhrDq8hUtaJG8dCxp61BVxTT9Wk31THWlY=; b=Rg9yxag01PlBd7MCqdivAnk2aM/lrJCdBlWrOnbnFZnf0TUtC4nMBrpssKr+GsPkd8wJZ/ 76k9os9g2vbfu0S3FWUFqMW672SG1xWRqL+9zHyneRKrJpj2RxfuHnpAgJdxWp1mbLNqc2 TfV7eVJS8XxN+l9N9TyG1fSPev6QhL4= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-16-jbGJBpHSP3mcn-l96ZXSpQ-1; Tue, 12 Sep 2023 09:15:46 -0400 X-MC-Unique: jbGJBpHSP3mcn-l96ZXSpQ-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2be63489592so38220761fa.1 for ; Tue, 12 Sep 2023 06:15:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694524544; x=1695129344; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Wh2SuiMd5ZhrDq8hUtaJG8dCxp61BVxTT9Wk31THWlY=; b=or9/p+O7g3tuyi3Ecq6chIDSHzYFFT7FznjRTGSyrekMFqDkGnP2ldu2nC5qvhmGE8 8BIZg0lxG6nFRo7AGQRn1VE84bdrh/ZMXmn7d5yHmLZb9Cj/PDVfv2oiDPbxLmfA4Os9 VlSIXH1vVk7Y6nbvVDsNXOw2t3mvLY6hhG+EuGtAYBV8GsqNOtLXJWu0ACI5zrmnattW oWR4fmZGxi66hv//2iHtvXuvFX9IVjd7/G26sdFcbbGQ15liHPVoQAiYx0ls2hk+yEYg D20tAGKB+H9ZJbJfN11Mmden1xRiCkSCjPwhqEQW5/fByqJMNIg2QTU6wzss2r5TIotj ERcQ== X-Gm-Message-State: AOJu0Yx87ixxScfmdODDhu9VRxv9wDLuPj//3Jv2ty+NuliMdyQ2xcsk bv6KeG3P6ygkiEasSZwwmH+mq+UUsiwVPsnj7VrFHKNO8ExRVixtx7epTq8dvPgYr4c0bq2z7B6 nfcnELp/pjJY4jCLYvFJGKIZBvZRR+aQGJHxknk0= X-Received: by 2002:a2e:86c2:0:b0:2b6:eceb:9b8 with SMTP id n2-20020a2e86c2000000b002b6eceb09b8mr894149ljj.10.1694524544593; Tue, 12 Sep 2023 06:15:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEbimH7GBmV9gjRs0A6c7G9ZyPh97YF7Ss9umAWPkSuHTs2QmMk4H3mhhWg+A0DYWcypW047Zk8D3RXXV5GiAc= X-Received: by 2002:a2e:86c2:0:b0:2b6:eceb:9b8 with SMTP id n2-20020a2e86c2000000b002b6eceb09b8mr894142ljj.10.1694524544276; Tue, 12 Sep 2023 06:15:44 -0700 (PDT) MIME-Version: 1.0 References: <20230912010852.1027184-1-ppalka@redhat.com> <7975a204-228b-d2ef-cb9b-5ab4e71f1efe@idea> In-Reply-To: <7975a204-228b-d2ef-cb9b-5ab4e71f1efe@idea> From: Jonathan Wakely Date: Tue, 12 Sep 2023 14:15:33 +0100 Message-ID: Subject: Re: [PATCH 1/3] libstdc++: Remove std::bind_front specialization for no bound args 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=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, 12 Sept 2023 at 13:46, Patrick Palka via Libstdc++ wrote: > > On Mon, 11 Sep 2023, Patrick Palka wrote: > > > This specialization for the case of no bound args, added by > > r13-4214-gcbd05ca5ab1231, seems to be mostly obsoleted by > > r13-5033-ge2eab3c4edb6aa which added [[no_unique_address]] to the > > main template's data members. And the compile time advantage of > > avoiding an empty tuple and index_sequence seems minimal. Removing this > > specialization also means we don't have to fix the PR111327 bug in > > another place. > > FWIW I don't feel strongly about removing this specialization. If we > keep it We'd at least be able to reuse it for std::bind_back, and it > wouldn't be hard to fix the PR111327 bug in its implementation. Yeah, I'm ambivalent. But since you've got a patch to fix 111327 ready which doesn't include this specialization, let's remove it. The empty std::tuple is at least already explicitly specialized, so I agree its overhead probably isn't very significant. OK for trunk. I'm not sure if we should change it in gcc-13 now though. > > > > > PR libstdc++/111327 > > > > libstdc++-v3/ChangeLog: > > > > * include/std/functional (_Bind_front0): Remove. > > (_Bind_front_t): Adjust. > > --- > > libstdc++-v3/include/std/functional | 63 +---------------------------- > > 1 file changed, 1 insertion(+), 62 deletions(-) > > > > diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional > > index 60d4d1f3dd2..7d1b890bb4e 100644 > > --- a/libstdc++-v3/include/std/functional > > +++ b/libstdc++-v3/include/std/functional > > @@ -996,69 +996,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > [[no_unique_address]] std::tuple<_BoundArgs...> _M_bound_args; > > }; > > > > - // Avoid the overhead of an empty tuple<> if there are no bound args. > > - template > > - struct _Bind_front0 > > - { > > - static_assert(is_move_constructible_v<_Fd>); > > - > > - // First parameter is to ensure this constructor is never used > > - // instead of the copy/move constructor. > > - template > > - explicit constexpr > > - _Bind_front0(int, _Fn&& __fn) > > - noexcept(is_nothrow_constructible_v<_Fd, _Fn>) > > - : _M_fd(std::forward<_Fn>(__fn)) > > - { } > > - > > - _Bind_front0(const _Bind_front0&) = default; > > - _Bind_front0(_Bind_front0&&) = default; > > - _Bind_front0& operator=(const _Bind_front0&) = default; > > - _Bind_front0& operator=(_Bind_front0&&) = default; > > - ~_Bind_front0() = default; > > - > > - template > > - constexpr > > - invoke_result_t<_Fd&, _CallArgs...> > > - operator()(_CallArgs&&... __call_args) & > > - noexcept(is_nothrow_invocable_v<_Fd&, _CallArgs...>) > > - { return std::invoke(_M_fd, std::forward<_CallArgs>(__call_args)...); } > > - > > - template > > - constexpr > > - invoke_result_t > > - operator()(_CallArgs&&... __call_args) const & > > - noexcept(is_nothrow_invocable_v) > > - { return std::invoke(_M_fd, std::forward<_CallArgs>(__call_args)...); } > > - > > - template > > - constexpr > > - invoke_result_t<_Fd, _CallArgs...> > > - operator()(_CallArgs&&... __call_args) && > > - noexcept(is_nothrow_invocable_v<_Fd, _CallArgs...>) > > - { > > - return std::invoke(std::move(_M_fd), > > - std::forward<_CallArgs>(__call_args)...); > > - } > > - > > - template > > - constexpr > > - invoke_result_t > > - operator()(_CallArgs&&... __call_args) const && > > - noexcept(is_nothrow_invocable_v) > > - { > > - return std::invoke(std::move(_M_fd), > > - std::forward<_CallArgs>(__call_args)...); > > - } > > - > > - private: > > - [[no_unique_address]] _Fd _M_fd; > > - }; > > - > > template > > - using _Bind_front_t > > - = __conditional_t>, > > - _Bind_front, decay_t<_Args>...>>; > > + using _Bind_front_t = _Bind_front, decay_t<_Args>...>; > > > > /** Create call wrapper by partial application of arguments to function. > > * > > -- > > 2.42.0.158.g94e83dcf5b > > > > >