diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-08-30 17:16:53 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-09-04 14:31:27 +0200 |
commit | b1be432485274a036b77ff04d7fb50bb4718e6b5 (patch) | |
tree | d20d6f098ae6cfcea11542845f611d9dfc0e0611 | |
parent | 470e409159af6ff4564d054ab7a4ab78c463eac2 (diff) | |
download | qtwebengine-chromium-b1be432485274a036b77ff04d7fb50bb4718e6b5.tar.gz |
[Revert] Remove base::internal::PassingTraits
This simplification doesn't work on MSVC 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 <michal.klocek@qt.io>
-rw-r--r-- | chromium/base/bind_internal.h | 5 | ||||
-rw-r--r-- | chromium/base/callback.h | 4 | ||||
-rw-r--r-- | 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 bf4a51b5a83..85fcc50a58a 100644 --- a/chromium/base/bind_internal.h +++ b/chromium/base/bind_internal.h @@ -631,7 +631,7 @@ struct Invoker; template <typename StorageType, typename R, typename... UnboundArgs> struct Invoker<StorageType, R(UnboundArgs...)> { static R RunOnce(BindStateBase* base, - PassingType<UnboundArgs>... unbound_args) { + PassingTraitsType<UnboundArgs>... 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. @@ -644,7 +644,8 @@ struct Invoker<StorageType, R(UnboundArgs...)> { std::forward<UnboundArgs>(unbound_args)...); } - static R Run(BindStateBase* base, PassingType<UnboundArgs>... unbound_args) { + static R Run(BindStateBase* base, + PassingTraitsType<UnboundArgs>... 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 e08f9b872b7..59bee1caef0 100644 --- a/chromium/base/callback.h +++ b/chromium/base/callback.h @@ -58,7 +58,7 @@ class OnceCallback<R(Args...)> : public internal::CallbackBase { public: using RunType = R(Args...); using PolymorphicInvoke = R (*)(internal::BindStateBase*, - internal::PassingType<Args>...); + internal::PassingTraitsType<Args>...); constexpr OnceCallback() = default; OnceCallback(std::nullptr_t) = delete; @@ -104,7 +104,7 @@ class RepeatingCallback<R(Args...)> : public internal::CallbackBaseCopyable { public: using RunType = R(Args...); using PolymorphicInvoke = R (*)(internal::BindStateBase*, - internal::PassingType<Args>...); + internal::PassingTraitsType<Args>...); constexpr RepeatingCallback() = default; RepeatingCallback(std::nullptr_t) = delete; diff --git a/chromium/base/callback_internal.h b/chromium/base/callback_internal.h index 777397d88a3..d3ec6108882 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 <typename T, bool IsScalar = std::is_scalar<T>::value> +struct PassingTraits; + +template <typename T> +struct PassingTraits<T, false> { + using Type = T&&; +}; + +template <typename T> +struct PassingTraits<T, true> { + using Type = T; +}; + template <typename T> -using PassingType = std::conditional_t<std::is_scalar<T>::value, T, T&&>; +using PassingTraitsType = typename PassingTraits<T>::Type; // BindStateBase is used to provide an opaque handle that the Callback // class can use to represent a function object with bound arguments. It |