| 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 28 matching lines...) Expand all Loading... |
| 39 // invocation manner for a Functor. This is where function | 39 // invocation manner for a Functor. This is where function |
| 40 // signature adapters are applied. | 40 // signature adapters are applied. |
| 41 // InvokeHelper<> -- Take a Functor + arguments and actully invokes it. | 41 // InvokeHelper<> -- Take a Functor + arguments and actully invokes it. |
| 42 // Handle the differing syntaxes needed for WeakPtr<> | 42 // Handle the differing syntaxes needed for WeakPtr<> |
| 43 // support. This is separate from Invoker to avoid creating | 43 // support. This is separate from Invoker to avoid creating |
| 44 // multiple version of Invoker<>. | 44 // multiple version of Invoker<>. |
| 45 // Invoker<> -- Unwraps the curried parameters and executes the Functor. | 45 // Invoker<> -- Unwraps the curried parameters and executes the Functor. |
| 46 // BindState<> -- Stores the curried parameters, and is the main entry point | 46 // BindState<> -- Stores the curried parameters, and is the main entry point |
| 47 // into the Bind() system. | 47 // into the Bind() system. |
| 48 | 48 |
| 49 template <typename...> | |
| 50 struct make_void { | |
| 51 using type = void; | |
| 52 }; | |
| 53 | |
| 54 // A clone of C++17 std::void_t. | |
| 55 // Unlike the original version, we need |make_void| as a helper struct to avoid | |
| 56 // a C++14 defect. | |
| 57 // ref: http://en.cppreference.com/w/cpp/types/void_t | |
| 58 // ref: http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1558 | |
| 59 template <typename... Ts> | |
| 60 using void_t = typename make_void<Ts...>::type; | |
| 61 | |
| 62 template <typename Callable, | 49 template <typename Callable, |
| 63 typename Signature = decltype(&Callable::operator())> | 50 typename Signature = decltype(&Callable::operator())> |
| 64 struct ExtractCallableRunTypeImpl; | 51 struct ExtractCallableRunTypeImpl; |
| 65 | 52 |
| 66 template <typename Callable, typename R, typename... Args> | 53 template <typename Callable, typename R, typename... Args> |
| 67 struct ExtractCallableRunTypeImpl<Callable, R(Callable::*)(Args...) const> { | 54 struct ExtractCallableRunTypeImpl<Callable, R(Callable::*)(Args...) const> { |
| 68 using Type = R(Args...); | 55 using Type = R(Args...); |
| 69 }; | 56 }; |
| 70 | 57 |
| 71 // Evaluated to RunType of the given callable type. | 58 // Evaluated to RunType of the given callable type. |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 | 513 |
| 527 // Returns a RunType of bound functor. | 514 // Returns a RunType of bound functor. |
| 528 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). | 515 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). |
| 529 template <typename Functor, typename... BoundArgs> | 516 template <typename Functor, typename... BoundArgs> |
| 530 using MakeUnboundRunType = | 517 using MakeUnboundRunType = |
| 531 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; | 518 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; |
| 532 | 519 |
| 533 } // namespace base | 520 } // namespace base |
| 534 | 521 |
| 535 #endif // BASE_BIND_INTERNAL_H_ | 522 #endif // BASE_BIND_INTERNAL_H_ |
| OLD | NEW |