From 483b62a868c78f04247a61bab254844750b79bfa Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 30 Aug 2018 17:16:53 +0200 Subject: [Revert] Remove base::internal::PassingTraits This simplification doesn't work on MSVC 2017 due to some MSVC bug, so stick with the old version for now. Reverting https://chromium-review.googlesource.com/1118061 Change-Id: I3dff6075f9cc37dcc39c26b4f24de0501c8a362f Reviewed-by: Michal Klocek --- chromium/base/bind_internal.h | 5 +++-- chromium/base/callback.h | 4 ++-- chromium/base/callback_internal.h | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/chromium/base/bind_internal.h b/chromium/base/bind_internal.h index 02c06b7b584..18f3bfa0a32 100644 --- a/chromium/base/bind_internal.h +++ b/chromium/base/bind_internal.h @@ -630,7 +630,7 @@ struct Invoker; template struct Invoker { static R RunOnce(BindStateBase* base, - PassingType... unbound_args) { + PassingTraitsType... unbound_args) { // Local references to make debugger stepping easier. If in a debugger, // you really want to warp ahead and step through the // InvokeHelper<>::MakeItSo() call below. @@ -643,7 +643,8 @@ struct Invoker { std::forward(unbound_args)...); } - static R Run(BindStateBase* base, PassingType... unbound_args) { + static R Run(BindStateBase* base, + PassingTraitsType... unbound_args) { // Local references to make debugger stepping easier. If in a debugger, // you really want to warp ahead and step through the // InvokeHelper<>::MakeItSo() call below. diff --git a/chromium/base/callback.h b/chromium/base/callback.h index 1427faaaea9..fde82605f25 100644 --- a/chromium/base/callback.h +++ b/chromium/base/callback.h @@ -58,7 +58,7 @@ class OnceCallback : public internal::CallbackBase { public: using RunType = R(Args...); using PolymorphicInvoke = R (*)(internal::BindStateBase*, - internal::PassingType...); + internal::PassingTraitsType...); constexpr OnceCallback() = default; OnceCallback(std::nullptr_t) = delete; @@ -104,7 +104,7 @@ class RepeatingCallback : public internal::CallbackBaseCopyable { public: using RunType = R(Args...); using PolymorphicInvoke = R (*)(internal::BindStateBase*, - internal::PassingType...); + internal::PassingTraitsType...); constexpr RepeatingCallback() = default; RepeatingCallback(std::nullptr_t) = delete; diff --git a/chromium/base/callback_internal.h b/chromium/base/callback_internal.h index fdfdf7f8175..cbdb0c724c7 100644 --- a/chromium/base/callback_internal.h +++ b/chromium/base/callback_internal.h @@ -36,8 +36,21 @@ struct BindStateBaseRefCountTraits { static void Destruct(const BindStateBase*); }; +template ::value> +struct PassingTraits; + +template +struct PassingTraits { + using Type = T&&; +}; + +template +struct PassingTraits { + using Type = T; +}; + template -using PassingType = std::conditional_t::value, T, T&&>; +using PassingTraitsType = typename PassingTraits::Type; // BindStateBase is used to provide an opaque handle that the Callback // class can use to represent a function object with bound arguments. It -- cgit v1.2.1