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 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 | 511 |
525 // Returns a RunType of bound functor. | 512 // Returns a RunType of bound functor. |
526 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). | 513 // E.g. MakeUnboundRunType<R(A, B, C), A, B> is evaluated to R(C). |
527 template <typename Functor, typename... BoundArgs> | 514 template <typename Functor, typename... BoundArgs> |
528 using MakeUnboundRunType = | 515 using MakeUnboundRunType = |
529 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; | 516 typename internal::MakeUnboundRunTypeImpl<Functor, BoundArgs...>::Type; |
530 | 517 |
531 } // namespace base | 518 } // namespace base |
532 | 519 |
533 #endif // BASE_BIND_INTERNAL_H_ | 520 #endif // BASE_BIND_INTERNAL_H_ |
OLD | NEW |