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> | 2020-02-05 15:32:16 +0100 |
commit | 483b62a868c78f04247a61bab254844750b79bfa (patch) | |
tree | 8872a33d06f16ede1a9bc096e0bc981409d0f118 | |
parent | 508cafdf32b20f7ca242131f1de4e739179b1e48 (diff) | |
download | qtwebengine-chromium-483b62a868c78f04247a61bab254844750b79bfa.tar.gz |
[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 <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 02c06b7b584..18f3bfa0a32 100644 --- a/chromium/base/bind_internal.h +++ b/chromium/base/bind_internal.h @@ -630,7 +630,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. @@ -643,7 +643,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 1427faaaea9..fde82605f25 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 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 <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 |