diff options
author | tzik <tzik@chromium.org> | 2016-02-01 22:09:35 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-02 06:10:26 +0000 |
commit | cdec75e36dd5ec9c5643f7b473e166a3acef81ea (patch) | |
tree | 6c97649d27a20050d5bbf3fb13d76a732fccb3f4 /base/bind.h | |
parent | 9bdb6bc2d91c210e23f3bde2401420df28c13641 (diff) | |
download | chromium_src-cdec75e36dd5ec9c5643f7b473e166a3acef81ea.zip chromium_src-cdec75e36dd5ec9c5643f7b473e166a3acef81ea.tar.gz chromium_src-cdec75e36dd5ec9c5643f7b473e166a3acef81ea.tar.bz2 |
Do Perfect Forwarding from base::Bind to BindState storage
Replace StorageType usage with std::decay and do Perfect Forwarding from
base::Bind to BindState storage as a preparation to store a move-only
type into BindState.
The difference of StorageType and std::decay is essentially array
handling. CallbackParamTraits::StorageType converts "T[n]" to "const T*"
OTOH std::decay converts it to "T*".
BUG=554299
Review URL: https://codereview.chromium.org/1644603003
Cr-Commit-Position: refs/heads/master@{#372900}
Diffstat (limited to 'base/bind.h')
-rw-r--r-- | base/bind.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/base/bind.h b/base/bind.h index 770e457..c6b7393 100644 --- a/base/bind.h +++ b/base/bind.h @@ -6,7 +6,6 @@ #define BASE_BIND_H_ #include "base/bind_internal.h" -#include "base/callback_internal.h" // ----------------------------------------------------------------------------- // Usage documentation @@ -52,9 +51,8 @@ base::Callback< typename internal::BindState< typename internal::FunctorTraits<Functor>::RunnableType, typename internal::FunctorTraits<Functor>::RunType, - typename internal::CallbackParamTraits<Args>::StorageType...> - ::UnboundRunType> -Bind(Functor functor, const Args&... args) { + typename std::decay<Args>::type...>::UnboundRunType> +Bind(Functor functor, Args&&... args) { // Type aliases for how to store and run the functor. using RunnableType = typename internal::FunctorTraits<Functor>::RunnableType; using RunType = typename internal::FunctorTraits<Functor>::RunType; @@ -89,11 +87,11 @@ Bind(Functor functor, const Args&... args) { "a parameter is a refcounted type and needs scoped_refptr"); using BindState = internal::BindState< - RunnableType, RunType, - typename internal::CallbackParamTraits<Args>::StorageType...>; + RunnableType, RunType, typename std::decay<Args>::type...>; return Callback<typename BindState::UnboundRunType>( - new BindState(internal::MakeRunnable(functor), args...)); + new BindState(internal::MakeRunnable(functor), + std::forward<Args>(args)...)); } } // namespace base |