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

Side by Side Diff: base/bind_internal.h

Issue 1457673002: styleguide: Allow enable_if, conditional, and other type_traits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rare usage note Created 5 years, 1 month 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
« no previous file with comments | « no previous file | base/callback_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 <type_traits>
9
8 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
9 #include "base/callback_internal.h" 11 #include "base/callback_internal.h"
10 #include "base/memory/raw_scoped_refptr_mismatch_checker.h" 12 #include "base/memory/raw_scoped_refptr_mismatch_checker.h"
11 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
12 #include "base/template_util.h" 14 #include "base/template_util.h"
13 #include "base/tuple.h" 15 #include "base/tuple.h"
14 #include "build/build_config.h" 16 #include "build/build_config.h"
15 17
16 #if defined(OS_WIN) 18 #if defined(OS_WIN)
17 #include "base/bind_internal_win.h" 19 #include "base/bind_internal_win.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // Implementation note: This non-specialized case handles zero-arity case only. 72 // Implementation note: This non-specialized case handles zero-arity case only.
71 // Non-zero-arity cases should be handled by the specialization below. 73 // Non-zero-arity cases should be handled by the specialization below.
72 template <typename Sig> 74 template <typename Sig>
73 struct HasNonConstReferenceParam : false_type {}; 75 struct HasNonConstReferenceParam : false_type {};
74 76
75 // Implementation note: Select true_type if the first parameter is a non-const 77 // Implementation note: Select true_type if the first parameter is a non-const
76 // reference. Otherwise, skip the first parameter and check rest of parameters 78 // reference. Otherwise, skip the first parameter and check rest of parameters
77 // recursively. 79 // recursively.
78 template <typename R, typename T, typename... Args> 80 template <typename R, typename T, typename... Args>
79 struct HasNonConstReferenceParam<R(T, Args...)> 81 struct HasNonConstReferenceParam<R(T, Args...)>
80 : SelectType<is_non_const_reference<T>::value, 82 : std::conditional<is_non_const_reference<T>::value,
81 true_type, 83 true_type,
82 HasNonConstReferenceParam<R(Args...)>>::Type {}; 84 HasNonConstReferenceParam<R(Args...)>>::type {};
83 85
84 // HasRefCountedTypeAsRawPtr selects true_type when any of the |Args| is a raw 86 // HasRefCountedTypeAsRawPtr selects true_type when any of the |Args| is a raw
85 // pointer to a RefCounted type. 87 // pointer to a RefCounted type.
86 // Implementation note: This non-specialized case handles zero-arity case only. 88 // Implementation note: This non-specialized case handles zero-arity case only.
87 // Non-zero-arity cases should be handled by the specialization below. 89 // Non-zero-arity cases should be handled by the specialization below.
88 template <typename... Args> 90 template <typename... Args>
89 struct HasRefCountedTypeAsRawPtr : false_type {}; 91 struct HasRefCountedTypeAsRawPtr : false_type {};
90 92
91 // Implementation note: Select true_type if the first parameter is a raw pointer 93 // Implementation note: Select true_type if the first parameter is a raw pointer
92 // to a RefCounted type. Otherwise, skip the first parameter and check rest of 94 // to a RefCounted type. Otherwise, skip the first parameter and check rest of
93 // parameters recursively. 95 // parameters recursively.
94 template <typename T, typename... Args> 96 template <typename T, typename... Args>
95 struct HasRefCountedTypeAsRawPtr<T, Args...> 97 struct HasRefCountedTypeAsRawPtr<T, Args...>
96 : SelectType<NeedsScopedRefptrButGetsRawPtr<T>::value, 98 : std::conditional<NeedsScopedRefptrButGetsRawPtr<T>::value,
97 true_type, 99 true_type,
98 HasRefCountedTypeAsRawPtr<Args...>>::Type {}; 100 HasRefCountedTypeAsRawPtr<Args...>>::type {};
99 101
100 // BindsArrayToFirstArg selects true_type when |is_method| is true and the first 102 // BindsArrayToFirstArg selects true_type when |is_method| is true and the first
101 // item of |Args| is an array type. 103 // item of |Args| is an array type.
102 // Implementation note: This non-specialized case handles !is_method case and 104 // Implementation note: This non-specialized case handles !is_method case and
103 // zero-arity case only. Other cases should be handled by the specialization 105 // zero-arity case only. Other cases should be handled by the specialization
104 // below. 106 // below.
105 template <bool is_method, typename... Args> 107 template <bool is_method, typename... Args>
106 struct BindsArrayToFirstArg : false_type {}; 108 struct BindsArrayToFirstArg : false_type {};
107 109
108 template <typename T, typename... Args> 110 template <typename T, typename... Args>
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 415
414 static void Destroy(BindStateBase* self) { 416 static void Destroy(BindStateBase* self) {
415 delete static_cast<BindState*>(self); 417 delete static_cast<BindState*>(self);
416 } 418 }
417 }; 419 };
418 420
419 } // namespace internal 421 } // namespace internal
420 } // namespace base 422 } // namespace base
421 423
422 #endif // BASE_BIND_INTERNAL_H_ 424 #endif // BASE_BIND_INTERNAL_H_
OLDNEW
« no previous file with comments | « no previous file | base/callback_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698