Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: base/bind_helpers.h

Issue 1512833002: Remove unbound base::Bind overload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 520
521 template <> 521 template <>
522 struct DropTypeListItemImpl<0, TypeList<>> { 522 struct DropTypeListItemImpl<0, TypeList<>> {
523 typedef TypeList<> Type; 523 typedef TypeList<> Type;
524 }; 524 };
525 525
526 // A type-level function that drops |n| list item from given TypeList. 526 // A type-level function that drops |n| list item from given TypeList.
527 template <size_t n, typename List> 527 template <size_t n, typename List>
528 using DropTypeListItem = typename DropTypeListItemImpl<n, List>::Type; 528 using DropTypeListItem = typename DropTypeListItemImpl<n, List>::Type;
529 529
530 // Used for TakeTypeListItem implementation.
531 template <size_t n, typename List, typename... Accum>
532 struct TakeTypeListItemImpl;
533
534 // Do not use enable_if and SFINAE here to avoid MSVC2013 compile failure.
535 template <size_t n, typename T, typename... List, typename... Accum>
536 struct TakeTypeListItemImpl<n, TypeList<T, List...>, Accum...>
537 : TakeTypeListItemImpl<n - 1, TypeList<List...>, Accum..., T> {};
538
539 template <typename T, typename... List, typename... Accum>
540 struct TakeTypeListItemImpl<0, TypeList<T, List...>, Accum...> {
541 using Type = TypeList<Accum...>;
542 };
543
544 template <typename... Accum>
545 struct TakeTypeListItemImpl<0, TypeList<>, Accum...> {
546 using Type = TypeList<Accum...>;
547 };
548
549 // A type-level function that takes first |n| list item from given TypeList.
550 // E.g. TakeTypeListItem<3, TypeList<A, B, C, D>> is evaluated to
551 // TypeList<A, B, C>.
552 template <size_t n, typename List>
553 using TakeTypeListItem = typename TakeTypeListItemImpl<n, List>::Type;
554
530 // Used for ConcatTypeLists implementation. 555 // Used for ConcatTypeLists implementation.
531 template <typename List1, typename List2> 556 template <typename List1, typename List2>
532 struct ConcatTypeListsImpl; 557 struct ConcatTypeListsImpl;
533 558
534 template <typename... Types1, typename... Types2> 559 template <typename... Types1, typename... Types2>
535 struct ConcatTypeListsImpl<TypeList<Types1...>, TypeList<Types2...>> { 560 struct ConcatTypeListsImpl<TypeList<Types1...>, TypeList<Types2...>> {
536 typedef TypeList<Types1..., Types2...> Type; 561 typedef TypeList<Types1..., Types2...> Type;
537 }; 562 };
538 563
539 // A type-level function that concats two TypeLists. 564 // A type-level function that concats two TypeLists.
540 template <typename List1, typename List2> 565 template <typename List1, typename List2>
541 using ConcatTypeLists = typename ConcatTypeListsImpl<List1, List2>::Type; 566 using ConcatTypeLists = typename ConcatTypeListsImpl<List1, List2>::Type;
542 567
543 // Used for MakeFunctionType implementation. 568 // Used for MakeFunctionType implementation.
544 template <typename R, typename ArgList> 569 template <typename R, typename ArgList>
545 struct MakeFunctionTypeImpl; 570 struct MakeFunctionTypeImpl;
546 571
547 template <typename R, typename... Args> 572 template <typename R, typename... Args>
548 struct MakeFunctionTypeImpl<R, TypeList<Args...>> { 573 struct MakeFunctionTypeImpl<R, TypeList<Args...>> {
549 typedef R(Type)(Args...); 574 typedef R(Type)(Args...);
550 }; 575 };
551 576
552 // A type-level function that constructs a function type that has |R| as its 577 // A type-level function that constructs a function type that has |R| as its
553 // return type and has TypeLists items as its arguments. 578 // return type and has TypeLists items as its arguments.
554 template <typename R, typename ArgList> 579 template <typename R, typename ArgList>
555 using MakeFunctionType = typename MakeFunctionTypeImpl<R, ArgList>::Type; 580 using MakeFunctionType = typename MakeFunctionTypeImpl<R, ArgList>::Type;
556 581
582 // Used for ExtractArgs.
583 template <typename Signature>
584 struct ExtractArgsImpl;
585
586 template <typename R, typename... Args>
587 struct ExtractArgsImpl<R(Args...)> {
588 using Type = TypeList<Args...>;
589 };
590
591 // A type-level function that extracts function arguments into a TypeList.
592 // E.g. ExtractArgs<R(A, B, C)> is evaluated to TypeList<A, B, C>.
593 template <typename Signature>
594 using ExtractArgs = typename ExtractArgsImpl<Signature>::Type;
595
557 } // namespace internal 596 } // namespace internal
558 597
559 template <typename T> 598 template <typename T>
560 static inline internal::UnretainedWrapper<T> Unretained(T* o) { 599 static inline internal::UnretainedWrapper<T> Unretained(T* o) {
561 return internal::UnretainedWrapper<T>(o); 600 return internal::UnretainedWrapper<T>(o);
562 } 601 }
563 602
564 template <typename T> 603 template <typename T>
565 static inline internal::ConstRefWrapper<T> ConstRef(const T& o) { 604 static inline internal::ConstRefWrapper<T> ConstRef(const T& o) {
566 return internal::ConstRefWrapper<T>(o); 605 return internal::ConstRefWrapper<T>(o);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 BASE_EXPORT void DoNothing(); 645 BASE_EXPORT void DoNothing();
607 646
608 template<typename T> 647 template<typename T>
609 void DeletePointer(T* obj) { 648 void DeletePointer(T* obj) {
610 delete obj; 649 delete obj;
611 } 650 }
612 651
613 } // namespace base 652 } // namespace base
614 653
615 #endif // BASE_BIND_HELPERS_H_ 654 #endif // BASE_BIND_HELPERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698