aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2023-09-12 11:23:08 -0400
committerPatrick Palka <ppalka@redhat.com>2023-09-12 11:23:08 -0400
commitf1e87aee5b7023fb4f5791c6869db705e18c2705 (patch)
tree01778265bfb6fd8140c995b3617fcd75c79540ee
parent3e4afea3b192c205c9a9da99f4cac65c68087eaf (diff)
downloadgcc-f1e87aee5b7023fb4f5791c6869db705e18c2705.zip
gcc-f1e87aee5b7023fb4f5791c6869db705e18c2705.tar.gz
gcc-f1e87aee5b7023fb4f5791c6869db705e18c2705.tar.bz2
libstdc++: Remove std::bind_front specialization for no bound args
The specialization used by std::bind_front when there are 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. What's left to consider is the compile time advantage of the specialization, which doesn't seem huge since it just avoids using tuple<> (which is an explicit specialization anyway) and expanding some pack expansions with an empty argument pack. So this patch removes this specialization; this means we have one less spot to fix the PR libstdc++/111327 perfect forwarding bug. libstdc++-v3/ChangeLog: * include/std/functional (_Bind_front0): Remove. (_Bind_front_t): Adjust.
-rw-r--r--libstdc++-v3/include/std/functional63
1 files changed, 1 insertions, 62 deletions
diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index 60d4d1f..7d1b890 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.
*