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 #include "base/callback.h" | 5 #include "base/callback.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 | 8 |
9 namespace base { | 9 namespace base { |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 // WeakPtrs cannot be bound to methods with return types. | 184 // WeakPtrs cannot be bound to methods with return types. |
185 void WontCompile() { | 185 void WontCompile() { |
186 NoRef no_ref; | 186 NoRef no_ref; |
187 WeakPtrFactory<NoRef> weak_factory(&no_ref); | 187 WeakPtrFactory<NoRef> weak_factory(&no_ref); |
188 Callback<int(void)> weak_ptr_with_non_void_return_type = | 188 Callback<int(void)> weak_ptr_with_non_void_return_type = |
189 Bind(&NoRef::IntMethod0, weak_factory.GetWeakPtr()); | 189 Bind(&NoRef::IntMethod0, weak_factory.GetWeakPtr()); |
190 weak_ptr_with_non_void_return_type.Run(); | 190 weak_ptr_with_non_void_return_type.Run(); |
191 } | 191 } |
192 | 192 |
193 #elif defined(NCTEST_DISALLOW_ASSIGN_DIFFERENT_TYPES) // [r"fatal error: no via
ble conversion from 'Callback<typename internal::BindState<typename internal::Fu
nctorTraits<void \(\*\)\(int\)>::RunnableType, typename internal::FunctorTraits<
void \(\*\)\(int\)>::RunType, void \(\)>::UnboundRunType>' to 'Callback<void \(\
)>'"] | 193 #elif defined(NCTEST_DISALLOW_ASSIGN_DIFFERENT_TYPES) // [r"fatal error: no via
ble conversion from 'Callback<typename internal::BindState<typename internal::Fu
nctorTraits<void \(\*\)\(int\)>::RunnableType, typename internal::FunctorTraits<
void \(\*\)\(int\)>::RunType, internal::TypeList<> >::UnboundRunType>' to 'Callb
ack<void \(\)>'"] |
194 | 194 |
195 // Bind result cannot be assigned to Callbacks with a mismatching type. | 195 // Bind result cannot be assigned to Callbacks with a mismatching type. |
196 void WontCompile() { | 196 void WontCompile() { |
197 Closure callback_mismatches_bind_type = Bind(&VoidPolymorphic1<int>); | 197 Closure callback_mismatches_bind_type = Bind(&VoidPolymorphic1<int>); |
198 } | 198 } |
199 | 199 |
200 #endif | 200 #endif |
201 | 201 |
202 } // namespace base | 202 } // namespace base |
OLD | NEW |