OLD | NEW |
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 353 |
354 using DecayedArgsTuple = typename std::decay<BoundArgsTuple>::type; | 354 using DecayedArgsTuple = typename std::decay<BoundArgsTuple>::type; |
355 static constexpr bool is_weak_call = | 355 static constexpr bool is_weak_call = |
356 IsWeakMethod<is_method, | 356 IsWeakMethod<is_method, |
357 typename std::tuple_element< | 357 typename std::tuple_element< |
358 indices, | 358 indices, |
359 DecayedArgsTuple>::type...>::value; | 359 DecayedArgsTuple>::type...>::value; |
360 | 360 |
361 return InvokeHelper<is_weak_call, R>::MakeItSo( | 361 return InvokeHelper<is_weak_call, R>::MakeItSo( |
362 std::forward<Functor>(functor), | 362 std::forward<Functor>(functor), |
363 Unwrap(base::get<indices>(std::forward<BoundArgsTuple>(bound)))..., | 363 Unwrap(std::get<indices>(std::forward<BoundArgsTuple>(bound)))..., |
364 std::forward<UnboundArgs>(unbound_args)...); | 364 std::forward<UnboundArgs>(unbound_args)...); |
365 } | 365 } |
366 }; | 366 }; |
367 | 367 |
368 // Used to implement MakeUnboundRunType. | 368 // Used to implement MakeUnboundRunType. |
369 template <typename Functor, typename... BoundArgs> | 369 template <typename Functor, typename... BoundArgs> |
370 struct MakeUnboundRunTypeImpl { | 370 struct MakeUnboundRunTypeImpl { |
371 using RunType = | 371 using RunType = |
372 typename FunctorTraits<typename std::decay<Functor>::type>::RunType; | 372 typename FunctorTraits<typename std::decay<Functor>::type>::RunType; |
373 using ReturnType = ExtractReturnType<RunType>; | 373 using ReturnType = ExtractReturnType<RunType>; |
(...skipping 12 matching lines...) Expand all Loading... |
386 IsNull(const Functor&) { | 386 IsNull(const Functor&) { |
387 return false; | 387 return false; |
388 } | 388 } |
389 | 389 |
390 // Used by ApplyCancellationTraits below. | 390 // Used by ApplyCancellationTraits below. |
391 template <typename Functor, typename BoundArgsTuple, size_t... indices> | 391 template <typename Functor, typename BoundArgsTuple, size_t... indices> |
392 bool ApplyCancellationTraitsImpl(const Functor& functor, | 392 bool ApplyCancellationTraitsImpl(const Functor& functor, |
393 const BoundArgsTuple& bound_args, | 393 const BoundArgsTuple& bound_args, |
394 IndexSequence<indices...>) { | 394 IndexSequence<indices...>) { |
395 return CallbackCancellationTraits<Functor, BoundArgsTuple>::IsCancelled( | 395 return CallbackCancellationTraits<Functor, BoundArgsTuple>::IsCancelled( |
396 functor, base::get<indices>(bound_args)...); | 396 functor, std::get<indices>(bound_args)...); |
397 } | 397 } |
398 | 398 |
399 // Relays |base| to corresponding CallbackCancellationTraits<>::Run(). Returns | 399 // Relays |base| to corresponding CallbackCancellationTraits<>::Run(). Returns |
400 // true if the callback |base| represents is canceled. | 400 // true if the callback |base| represents is canceled. |
401 template <typename BindStateType> | 401 template <typename BindStateType> |
402 bool ApplyCancellationTraits(const BindStateBase* base) { | 402 bool ApplyCancellationTraits(const BindStateBase* base) { |
403 const BindStateType* storage = static_cast<const BindStateType*>(base); | 403 const BindStateType* storage = static_cast<const BindStateType*>(base); |
404 static constexpr size_t num_bound_args = | 404 static constexpr size_t num_bound_args = |
405 std::tuple_size<decltype(storage->bound_args_)>::value; | 405 std::tuple_size<decltype(storage->bound_args_)>::value; |
406 return ApplyCancellationTraitsImpl(storage->functor_, storage->bound_args_, | 406 return ApplyCancellationTraitsImpl(storage->functor_, storage->bound_args_, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 534 |
535 // Returns a RunType of bound functor. | 535 // Returns a RunType of bound functor. |
536 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). | 536 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). |
537 template <typename Functor, typename... BoundArgs> | 537 template <typename Functor, typename... BoundArgs> |
538 using MakeUnboundRunType = | 538 using MakeUnboundRunType = |
539 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; | 539 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; |
540 | 540 |
541 } // namespace base | 541 } // namespace base |
542 | 542 |
543 #endif // BASE_BIND_INTERNAL_H_ | 543 #endif // BASE_BIND_INTERNAL_H_ |
OLD | NEW |