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 // This defines a set of argument wrappers and related factory methods that | 5 // This defines a set of argument wrappers and related factory methods that |
6 // can be used specify the refcounting and reference semantics of arguments | 6 // can be used specify the refcounting and reference semantics of arguments |
7 // that are bound by the Bind() function in base/bind.h. | 7 // that are bound by the Bind() function in base/bind.h. |
8 // | 8 // |
9 // It also defines a set of simple functions and utilities that people want | 9 // It also defines a set of simple functions and utilities that people want |
10 // when using Callback<> and Bind(). | 10 // when using Callback<> and Bind(). |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 528 |
529 template <typename... Types1, typename... Types2> | 529 template <typename... Types1, typename... Types2> |
530 struct ConcatTypeListsImpl<TypeList<Types1...>, TypeList<Types2...>> { | 530 struct ConcatTypeListsImpl<TypeList<Types1...>, TypeList<Types2...>> { |
531 typedef TypeList<Types1..., Types2...> Type; | 531 typedef TypeList<Types1..., Types2...> Type; |
532 }; | 532 }; |
533 | 533 |
534 // A type-level function that concats two TypeLists. | 534 // A type-level function that concats two TypeLists. |
535 template <typename List1, typename List2> | 535 template <typename List1, typename List2> |
536 using ConcatTypeLists = typename ConcatTypeListsImpl<List1, List2>::Type; | 536 using ConcatTypeLists = typename ConcatTypeListsImpl<List1, List2>::Type; |
537 | 537 |
538 template <size_t n, typename List> | |
539 struct NthTypeImpl; | |
540 | |
541 template <size_t n, typename T, typename... Types> | |
542 struct NthTypeImpl<n, TypeList<T, Types...>> | |
543 : NthTypeImpl<n - 1, TypeList<Types...>> { | |
544 }; | |
545 | |
546 template <typename T, typename... Types> | |
547 struct NthTypeImpl<0, TypeList<T, Types...>> { | |
548 typedef T Type; | |
549 }; | |
550 | |
551 // A type-level function that extracts |n|th type from a TypeList. | |
552 template <size_t n, typename List> | |
553 using NthType = typename NthTypeImpl<n, List>::Type; | |
554 | |
555 // Used for MakeFunctionType implementation. | 538 // Used for MakeFunctionType implementation. |
556 template <typename R, typename ArgList> | 539 template <typename R, typename ArgList> |
557 struct MakeFunctionTypeImpl; | 540 struct MakeFunctionTypeImpl; |
558 | 541 |
559 template <typename R, typename... Args> | 542 template <typename R, typename... Args> |
560 struct MakeFunctionTypeImpl<R, TypeList<Args...>> { | 543 struct MakeFunctionTypeImpl<R, TypeList<Args...>> { |
561 typedef R(Type)(Args...); | 544 typedef R(Type)(Args...); |
562 }; | 545 }; |
563 | 546 |
564 // A type-level function that constructs a function type that has |R| as its | 547 // A type-level function that constructs a function type that has |R| as its |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 BASE_EXPORT void DoNothing(); | 593 BASE_EXPORT void DoNothing(); |
611 | 594 |
612 template<typename T> | 595 template<typename T> |
613 void DeletePointer(T* obj) { | 596 void DeletePointer(T* obj) { |
614 delete obj; | 597 delete obj; |
615 } | 598 } |
616 | 599 |
617 } // namespace base | 600 } // namespace base |
618 | 601 |
619 #endif // BASE_BIND_HELPERS_H_ | 602 #endif // BASE_BIND_HELPERS_H_ |
OLD | NEW |