OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "weak_ptr_factory.h" | 5 #include "weak_ptr_factory.h" |
6 | 6 |
7 namespace should_succeed { | 7 namespace should_succeed { |
8 | 8 |
9 class OnlyMember { | 9 class OnlyMember { |
10 base::WeakPtrFactory<OnlyMember> factory_; | 10 base::WeakPtrFactory<OnlyMember> factory_; |
(...skipping 17 matching lines...) Expand all Loading... |
28 base::WeakPtrFactory<FirstFactoryRefersToOtherType> factory_; | 28 base::WeakPtrFactory<FirstFactoryRefersToOtherType> factory_; |
29 }; | 29 }; |
30 | 30 |
31 class TwoFactories { | 31 class TwoFactories { |
32 bool bool_member_; | 32 bool bool_member_; |
33 int int_member_; | 33 int int_member_; |
34 base::WeakPtrFactory<TwoFactories> factory1_; | 34 base::WeakPtrFactory<TwoFactories> factory1_; |
35 base::WeakPtrFactory<TwoFactories> factory2_; | 35 base::WeakPtrFactory<TwoFactories> factory2_; |
36 }; | 36 }; |
37 | 37 |
| 38 template <class T> |
| 39 class ClassTemplate { |
| 40 public: |
| 41 ClassTemplate() : factory_(this) {} |
| 42 private: |
| 43 bool bool_member_; |
| 44 base::WeakPtrFactory<ClassTemplate> factory_; |
| 45 }; |
| 46 // Make sure the template gets instantiated: |
| 47 ClassTemplate<int> g_instance; |
| 48 |
38 } // namespace should_succeed | 49 } // namespace should_succeed |
39 | 50 |
40 namespace should_fail { | 51 namespace should_fail { |
41 | 52 |
42 class FactoryFirst { | 53 class FactoryFirst { |
43 base::WeakPtrFactory<FactoryFirst> factory_; | 54 base::WeakPtrFactory<FactoryFirst> factory_; |
44 int int_member; | 55 int int_member; |
45 }; | 56 }; |
46 | 57 |
47 class FactoryMiddle { | 58 class FactoryMiddle { |
48 bool bool_member_; | 59 bool bool_member_; |
49 base::WeakPtrFactory<FactoryMiddle> factory_; | 60 base::WeakPtrFactory<FactoryMiddle> factory_; |
50 int int_member_; | 61 int int_member_; |
51 }; | 62 }; |
52 | 63 |
53 class TwoFactoriesOneBad { | 64 class TwoFactoriesOneBad { |
54 bool bool_member_; | 65 bool bool_member_; |
55 base::WeakPtrFactory<TwoFactoriesOneBad> factory1_; | 66 base::WeakPtrFactory<TwoFactoriesOneBad> factory1_; |
56 int int_member_; | 67 int int_member_; |
57 base::WeakPtrFactory<TwoFactoriesOneBad> factory2_; | 68 base::WeakPtrFactory<TwoFactoriesOneBad> factory2_; |
58 }; | 69 }; |
59 | 70 |
| 71 template <class T> |
| 72 class ClassTemplate { |
| 73 public: |
| 74 ClassTemplate() : factory_(this) {} |
| 75 private: |
| 76 base::WeakPtrFactory<ClassTemplate> factory_; |
| 77 bool bool_member_; |
| 78 }; |
| 79 // Make sure the template gets instantiated: |
| 80 ClassTemplate<int> g_instance; |
| 81 |
60 } // namespace should_fail | 82 } // namespace should_fail |
61 | 83 |
62 int main() { | 84 int main() { |
63 } | 85 } |
64 | 86 |
OLD | NEW |