Chromium Code Reviews| Index: base/bind_helpers.h |
| diff --git a/base/bind_helpers.h b/base/bind_helpers.h |
| index 434520ac2b2cfce4fc2b34005fe4e5b827536f6e..067f8ed7f711005128c8b6593bbe09f6102a8c00 100644 |
| --- a/base/bind_helpers.h |
| +++ b/base/bind_helpers.h |
| @@ -527,6 +527,29 @@ struct DropTypeListItemImpl<0, TypeList<>> { |
| template <size_t n, typename List> |
| using DropTypeListItem = typename DropTypeListItemImpl<n, List>::Type; |
| +// Used for TakeTypeListItem implementation. |
| +template <size_t n, typename List, typename... Accum> |
| +struct TakeTypeListItemImpl; |
| + |
| +// Do not use enable_if and SFINAE here to avoid MSVC2013 compile failure. |
| +template <size_t n, typename T, typename... List, typename... Accum> |
| +struct TakeTypeListItemImpl<n, TypeList<T, List...>, Accum...> |
| + : TakeTypeListItemImpl<n - 1, TypeList<List...>, Accum..., T> {}; |
| + |
| +template <typename T, typename... List, typename... Accum> |
| +struct TakeTypeListItemImpl<0, TypeList<T, List...>, Accum...> { |
| + typedef TypeList<Accum...> Type; |
|
dcheng
2015/12/14 19:26:46
Let's do using Type = TypeList<Accum...>;
tzik
2015/12/15 05:55:09
Done.
|
| +}; |
| + |
| +template <typename... Accum> |
| +struct TakeTypeListItemImpl<0, TypeList<>, Accum...> { |
| + typedef TypeList<Accum...> Type; |
| +}; |
| + |
| +// A type-level function that takes first |n| list item from given TypeList. |
|
dcheng
2015/12/14 19:26:46
Can this comment include an example input and the
tzik
2015/12/15 05:55:09
Done.
|
| +template <size_t n, typename List> |
| +using TakeTypeListItem = typename TakeTypeListItemImpl<n, List>::Type; |
| + |
| // Used for ConcatTypeLists implementation. |
| template <typename List1, typename List2> |
| struct ConcatTypeListsImpl; |
| @@ -554,6 +577,19 @@ struct MakeFunctionTypeImpl<R, TypeList<Args...>> { |
| template <typename R, typename ArgList> |
| using MakeFunctionType = typename MakeFunctionTypeImpl<R, ArgList>::Type; |
| +// Used for ExtractArgs. |
| +template <typename Signature> |
| +struct ExtractArgsImpl; |
| + |
| +template <typename R, typename... Args> |
| +struct ExtractArgsImpl<R(Args...)> { |
| + using Type = TypeList<Args...>; |
| +}; |
| + |
| +// A type-level function that extracts function arguments into a TypeList. |
|
dcheng
2015/12/14 19:26:46
Ditto:
Input: R(A1, A2, A3) => TypeList<A1, A2, A
tzik
2015/12/15 05:55:09
Done.
|
| +template <typename Signature> |
| +using ExtractArgs = typename ExtractArgsImpl<Signature>::Type; |
| + |
| } // namespace internal |
| template <typename T> |