OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/callback.h" |
| 6 #include "base/bind.h" |
| 7 |
| 8 namespace base { |
| 9 namespace { |
| 10 |
| 11 class NoRef { |
| 12 public: |
| 13 void VoidMethod0() {} |
| 14 }; |
| 15 |
| 16 class HasRef : public NoRef { |
| 17 public: |
| 18 void AddRef(void) const {} |
| 19 bool Release(void) const { return true; } |
| 20 }; |
| 21 |
| 22 int Identity(int n) { |
| 23 return n; |
| 24 } |
| 25 |
| 26 #if defined(TEST_METHOD_ON_CONST_OBJECT) // [r"invalid conversion from 'const b
ase::<unnamed>::NoRef\*' to 'base::<unnamed>::NoRef\*'"] |
| 27 |
| 28 // - Method bound to const-object. |
| 29 // |
| 30 // Only const methods should be allowed to work with const objects. |
| 31 |
| 32 void WontCompile() { |
| 33 HasRef has_ref; |
| 34 const HasRef* const_has_ref_ptr_ = &has_ref; |
| 35 Callback<void(void)> method_to_const_cb = |
| 36 Bind(&HasRef::VoidMethod0, const_has_ref_ptr_); |
| 37 method_to_const_cb.Run(); |
| 38 } |
| 39 |
| 40 |
| 41 #elif defined(TEST_SUPERTYPE_ASSIGNMENT) // [r"no match for 'operator=' in 'cb_
a1 = cb_b1'"] |
| 42 |
| 43 void WontCompile() { |
| 44 Callback<int(void)> cb_a1 = Bind(&Identity, 1); |
| 45 Callback<void(void)> cb_b1; |
| 46 cb_a1 = cb_b1; |
| 47 } |
| 48 |
| 49 #endif |
| 50 |
| 51 } // namespace |
| 52 } // namespace base |
OLD | NEW |