[MD settings] moving attached() code
[chromium-blink-merge.git] / tools / clang / plugins / tests / weak_ptr_factory.cpp
blobe9e6dd5116321e7635337a1116a98e4e64026e38
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
3 // found in the LICENSE file.
5 #include "weak_ptr_factory.h"
7 namespace should_succeed {
9 class OnlyMember {
10 base::WeakPtrFactory<OnlyMember> factory_;
13 class FactoryLast {
14 bool bool_member_;
15 int int_member_;
16 base::WeakPtrFactory<FactoryLast> factory_;
19 class FactoryRefersToOtherType {
20 bool bool_member_;
21 base::WeakPtrFactory<bool> bool_ptr_factory_;
24 class FirstFactoryRefersToOtherType {
25 bool bool_member_;
26 base::WeakPtrFactory<bool> bool_ptr_factory_;
27 int int_member_;
28 base::WeakPtrFactory<FirstFactoryRefersToOtherType> factory_;
31 class TwoFactories {
32 bool bool_member_;
33 int int_member_;
34 base::WeakPtrFactory<TwoFactories> factory1_;
35 base::WeakPtrFactory<TwoFactories> factory2_;
38 template <class T>
39 class ClassTemplate {
40 public:
41 ClassTemplate() : factory_(this) {}
42 private:
43 bool bool_member_;
44 base::WeakPtrFactory<ClassTemplate> factory_;
46 // Make sure the template gets instantiated:
47 ClassTemplate<int> g_instance;
49 } // namespace should_succeed
51 namespace should_fail {
53 class FactoryFirst {
54 base::WeakPtrFactory<FactoryFirst> factory_;
55 int int_member;
58 class FactoryMiddle {
59 bool bool_member_;
60 base::WeakPtrFactory<FactoryMiddle> factory_;
61 int int_member_;
64 class TwoFactoriesOneBad {
65 bool bool_member_;
66 base::WeakPtrFactory<TwoFactoriesOneBad> factory1_;
67 int int_member_;
68 base::WeakPtrFactory<TwoFactoriesOneBad> factory2_;
71 template <class T>
72 class ClassTemplate {
73 public:
74 ClassTemplate() : factory_(this) {}
75 private:
76 base::WeakPtrFactory<ClassTemplate> factory_;
77 bool bool_member_;
79 // Make sure the template gets instantiated:
80 ClassTemplate<int> g_instance;
82 } // namespace should_fail
84 int main() {