Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: base/callback.h

Issue 1498973002: WIP: base::Bind for rvalue references. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/bind_unittest.cc ('k') | base/callback_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_CALLBACK_H_ 5 #ifndef BASE_CALLBACK_H_
6 #define BASE_CALLBACK_H_ 6 #define BASE_CALLBACK_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/callback_internal.h" 9 #include "base/callback_internal.h"
10 #include "base/template_util.h" 10 #include "base/template_util.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 PolymorphicInvoke invoke_func = 381 PolymorphicInvoke invoke_func =
382 &internal::BindState<Runnable, BindRunType, BoundArgsType> 382 &internal::BindState<Runnable, BindRunType, BoundArgsType>
383 ::InvokerType::Run; 383 ::InvokerType::Run;
384 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func); 384 polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
385 } 385 }
386 386
387 bool Equals(const Callback& other) const { 387 bool Equals(const Callback& other) const {
388 return CallbackBase::Equals(other); 388 return CallbackBase::Equals(other);
389 } 389 }
390 390
391 R Run(typename internal::CallbackParamTraits<Args>::ForwardType... args) 391 template <typename... RunArgs>
392 const { 392 R Run(RunArgs&&... args) const {
393 PolymorphicInvoke f = 393 PolymorphicInvoke f =
394 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_); 394 reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
395 395
396 return f(bind_state_.get(), internal::CallbackForward(args)...); 396 return f(bind_state_.get(), std::forward<RunArgs>(args)...);
397 } 397 }
398 398
399 private: 399 private:
400 typedef R(*PolymorphicInvoke)( 400 typedef R (*PolymorphicInvoke)(
401 internal::BindStateBase*, 401 internal::BindStateBase*,
402 typename internal::CallbackParamTraits<Args>::ForwardType...); 402 typename internal::CallbackParamTraits<Args>::ForwardType...);
403 }; 403 };
404 404
405 // Syntactic sugar to make Callback<void(void)> easier to declare since it 405 // Syntactic sugar to make Callback<void(void)> easier to declare since it
406 // will be used in a lot of APIs with delayed execution. 406 // will be used in a lot of APIs with delayed execution.
407 typedef Callback<void(void)> Closure; 407 typedef Callback<void(void)> Closure;
408 408
409 } // namespace base 409 } // namespace base
410 410
411 #endif // BASE_CALLBACK_H_ 411 #endif // BASE_CALLBACK_H_
OLDNEW
« no previous file with comments | « base/bind_unittest.cc ('k') | base/callback_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698