public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH 1/3] libstdc++: Remove std::bind_front specialization for no bound args
Date: Tue, 12 Sep 2023 14:15:33 +0100	[thread overview]
Message-ID: <CACb0b4mc8x8LaCPk3TLKVTvMZRr_MsjkS=eEW2v_5YYW=KiLTg@mail.gmail.com> (raw)
In-Reply-To: <7975a204-228b-d2ef-cb9b-5ab4e71f1efe@idea>

On Tue, 12 Sept 2023 at 13:46, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> 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<typename _Fd>
> > -    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<typename _Fn>
> > -     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<typename... _CallArgs>
> > -     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<typename... _CallArgs>
> > -     constexpr
> > -     invoke_result_t<const _Fd&, _CallArgs...>
> > -     operator()(_CallArgs&&... __call_args) const &
> > -     noexcept(is_nothrow_invocable_v<const _Fd&, _CallArgs...>)
> > -     { return std::invoke(_M_fd, std::forward<_CallArgs>(__call_args)...); }
> > -
> > -      template<typename... _CallArgs>
> > -     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<typename... _CallArgs>
> > -     constexpr
> > -     invoke_result_t<const _Fd, _CallArgs...>
> > -     operator()(_CallArgs&&... __call_args) const &&
> > -     noexcept(is_nothrow_invocable_v<const _Fd, _CallArgs...>)
> > -     {
> > -       return std::invoke(std::move(_M_fd),
> > -                          std::forward<_CallArgs>(__call_args)...);
> > -     }
> > -
> > -    private:
> > -      [[no_unique_address]] _Fd _M_fd;
> > -    };
> > -
> >    template<typename _Fn, typename... _Args>
> > -    using _Bind_front_t
> > -      = __conditional_t<sizeof...(_Args) == 0, _Bind_front0<decay_t<_Fn>>,
> > -                     _Bind_front<decay_t<_Fn>, decay_t<_Args>...>>;
> > +    using _Bind_front_t = _Bind_front<decay_t<_Fn>, decay_t<_Args>...>;
> >
> >    /** Create call wrapper by partial application of arguments to function.
> >     *
> > --
> > 2.42.0.158.g94e83dcf5b
> >
> >
>


      reply	other threads:[~2023-09-12 13:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12  1:08 Patrick Palka
2023-09-12  1:08 ` [PATCH 2/3] libstdc++: Fix std::bind_front perfect forwarding [PR111327] Patrick Palka
2023-09-12 13:16   ` Jonathan Wakely
2023-09-12  1:08 ` [PATCH 3/3] libstdc++: Fix std::not_fn " Patrick Palka
2023-09-12 13:16   ` Jonathan Wakely
2023-09-12 12:46 ` [PATCH 1/3] libstdc++: Remove std::bind_front specialization for no bound args Patrick Palka
2023-09-12 13:15   ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACb0b4mc8x8LaCPk3TLKVTvMZRr_MsjkS=eEW2v_5YYW=KiLTg@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=ppalka@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).