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

Side by Side Diff: base/bind_internal.h

Issue 2298133003: Support rvalue-reference IgnoreResult in base::Bind impl (Closed)
Patch Set: Created 4 years, 3 months 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 | « no previous file | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BIND_INTERNAL_H_ 5 #ifndef BASE_BIND_INTERNAL_H_
6 #define BASE_BIND_INTERNAL_H_ 6 #define BASE_BIND_INTERNAL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <tuple> 10 #include <tuple>
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 237
238 // For IgnoreResults. 238 // For IgnoreResults.
239 template <typename T> 239 template <typename T>
240 struct FunctorTraits<IgnoreResultHelper<T>> : FunctorTraits<T> { 240 struct FunctorTraits<IgnoreResultHelper<T>> : FunctorTraits<T> {
241 using RunType = 241 using RunType =
242 typename ForceVoidReturn<typename FunctorTraits<T>::RunType>::RunType; 242 typename ForceVoidReturn<typename FunctorTraits<T>::RunType>::RunType;
243 243
244 template <typename IgnoreResultType, typename... RunArgs> 244 template <typename IgnoreResultType, typename... RunArgs>
245 static void Invoke(IgnoreResultType&& ignore_result_helper, 245 static void Invoke(IgnoreResultType&& ignore_result_helper,
246 RunArgs&&... args) { 246 RunArgs&&... args) {
247 FunctorTraits<T>::Invoke(ignore_result_helper.functor_, 247 FunctorTraits<T>::Invoke(
248 std::forward<RunArgs>(args)...); 248 std::forward<IgnoreResultType>(ignore_result_helper).functor_,
Yuta Kitamura 2016/08/31 09:38:21 Just to be sure: this change tries to make this ar
tzik 2016/08/31 09:51:11 Right. Updated the description for this.
249 std::forward<RunArgs>(args)...);
249 } 250 }
250 }; 251 };
251 252
252 // For Callbacks. 253 // For Callbacks.
253 template <typename R, typename... Args, CopyMode copy_mode> 254 template <typename R, typename... Args, CopyMode copy_mode>
254 struct FunctorTraits<Callback<R(Args...), copy_mode>> { 255 struct FunctorTraits<Callback<R(Args...), copy_mode>> {
255 using RunType = R(Args...); 256 using RunType = R(Args...);
256 static constexpr bool is_method = false; 257 static constexpr bool is_method = false;
257 static constexpr bool is_nullable = true; 258 static constexpr bool is_nullable = true;
258 259
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 374 }
374 375
375 // BindState<> 376 // BindState<>
376 // 377 //
377 // This stores all the state passed into Bind(). 378 // This stores all the state passed into Bind().
378 template <typename Functor, typename... BoundArgs> 379 template <typename Functor, typename... BoundArgs>
379 struct BindState final : BindStateBase { 380 struct BindState final : BindStateBase {
380 template <typename ForwardFunctor, typename... ForwardBoundArgs> 381 template <typename ForwardFunctor, typename... ForwardBoundArgs>
381 explicit BindState(ForwardFunctor&& functor, ForwardBoundArgs&&... bound_args) 382 explicit BindState(ForwardFunctor&& functor, ForwardBoundArgs&&... bound_args)
382 : BindStateBase(&Destroy), 383 : BindStateBase(&Destroy),
383 functor_(std::forward<ForwardFunctor>(functor)), 384 functor_(std::forward<ForwardFunctor>(functor)),
384 bound_args_(std::forward<ForwardBoundArgs>(bound_args)...) { 385 bound_args_(std::forward<ForwardBoundArgs>(bound_args)...) {
385 DCHECK(!IsNull(functor_)); 386 DCHECK(!IsNull(functor_));
386 } 387 }
387 388
388 Functor functor_; 389 Functor functor_;
389 std::tuple<BoundArgs...> bound_args_; 390 std::tuple<BoundArgs...> bound_args_;
390 391
391 private: 392 private:
392 ~BindState() {} 393 ~BindState() {}
393 394
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 445
445 // Returns a RunType of bound functor. 446 // Returns a RunType of bound functor.
446 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). 447 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C).
447 template <typename Functor, typename... BoundArgs> 448 template <typename Functor, typename... BoundArgs>
448 using MakeUnboundRunType = 449 using MakeUnboundRunType =
449 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; 450 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type;
450 451
451 } // namespace base 452 } // namespace base
452 453
453 #endif // BASE_BIND_INTERNAL_H_ 454 #endif // BASE_BIND_INTERNAL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698