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

Side by Side Diff: base/callback.h

Issue 2581943005: Explicitly delete some Callback constructors to improve errors.
Patch Set: MSVC doesn't implement type traits correctly. Created 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CALLBACK_H_ 5 #ifndef BASE_CALLBACK_H_
6 #define BASE_CALLBACK_H_ 6 #define BASE_CALLBACK_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/callback_internal.h" 9 #include "base/callback_internal.h"
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 using RunType = R(Args...); 110 using RunType = R(Args...);
111 111
112 Callback() : internal::CallbackBase<copy_mode>(nullptr) {} 112 Callback() : internal::CallbackBase<copy_mode>(nullptr) {}
113 113
114 explicit Callback(internal::BindStateBase* bind_state) 114 explicit Callback(internal::BindStateBase* bind_state)
115 : internal::CallbackBase<copy_mode>(bind_state) { 115 : internal::CallbackBase<copy_mode>(bind_state) {
116 } 116 }
117 117
118 template <typename OtherCallback, 118 template <typename OtherCallback,
119 typename = typename std::enable_if< 119 typename = typename std::enable_if<
120 internal::IsCallbackConvertible<OtherCallback, Callback>::value 120 internal::IsOnceCallback<OtherCallback>::value>::type>
121 >::type> 121 Callback(const OtherCallback&) = delete;
122
123 template <typename OtherCallback,
124 typename = typename std::enable_if<
125 internal::IsCallbackConvertible<OtherCallback,
126 Callback>::value>::type>
brucedawson 2016/12/19 19:16:00 The diffs are very confusing here - it took me a w
dcheng 2016/12/19 20:18:11 //base requires clang-formatting now =P Do you th
122 Callback(OtherCallback other) 127 Callback(OtherCallback other)
123 : internal::CallbackBase<copy_mode>(std::move(other)) {} 128 : internal::CallbackBase<copy_mode>(std::move(other)) {}
124 129
125 template <typename OtherCallback, 130 template <typename OtherCallback,
126 typename = typename std::enable_if< 131 typename = typename std::enable_if<
127 internal::IsCallbackConvertible<OtherCallback, Callback>::value 132 internal::IsCallbackConvertible<OtherCallback, Callback>::value
128 >::type> 133 >::type>
129 Callback& operator=(OtherCallback other) { 134 Callback& operator=(OtherCallback other) {
130 static_cast<internal::CallbackBase<copy_mode>&>(*this) = std::move(other); 135 static_cast<internal::CallbackBase<copy_mode>&>(*this) = std::move(other);
131 return *this; 136 return *this;
132 } 137 }
133 138
134 bool Equals(const Callback& other) const { 139 bool Equals(const Callback& other) const {
135 return this->EqualsInternal(other); 140 return this->EqualsInternal(other);
136 } 141 }
137 142
138 friend class internal::RunMixin<Callback>; 143 friend class internal::RunMixin<Callback>;
139 }; 144 };
140 145
141 } // namespace base 146 } // namespace base
142 147
143 #endif // BASE_CALLBACK_H_ 148 #endif // BASE_CALLBACK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698