Commit | Line | Data |
---|---|---|
258093ca MC |
1 | // 2002-05-13 |
2 | ||
3 | namespace __gnu_test | |
4 | { | |
5 | enum region { oriental, egyptian, greek, etruscan, roman }; | |
6 | ||
7 | // Test one. | |
8 | class gnu_obj_1 | |
9 | { | |
10 | protected: | |
11 | typedef region antiquities; | |
12 | static const bool test = true; | |
13 | static const int key1 = 5; | |
14 | static long key2; | |
15 | ||
16 | static antiquities value; | |
17 | ||
18 | public: | |
19 | gnu_obj_1(antiquities a, long l) {} | |
20 | }; | |
21 | ||
22 | const bool gnu_obj_1::test; | |
23 | const int gnu_obj_1::key1; | |
24 | long gnu_obj_1::key2 = 77; | |
25 | gnu_obj_1::antiquities gnu_obj_1::value = oriental; | |
26 | ||
27 | ||
28 | // Test two. | |
29 | template<typename T> | |
30 | class gnu_obj_2: public virtual gnu_obj_1 | |
31 | { | |
32 | public: | |
33 | static antiquities value_derived; | |
34 | ||
35 | public: | |
36 | gnu_obj_2(antiquities b): gnu_obj_1(oriental, 7) { } | |
37 | }; | |
38 | ||
39 | template<typename T> | |
40 | typename gnu_obj_2<T>::antiquities gnu_obj_2<T>::value_derived = etruscan; | |
41 | ||
42 | // Test three. | |
43 | template<typename T> | |
44 | class gnu_obj_3 | |
45 | { | |
46 | public: | |
47 | typedef region antiquities; | |
48 | static gnu_obj_2<int> data; | |
49 | ||
50 | public: | |
51 | gnu_obj_3(antiquities b) { } | |
52 | }; | |
53 | ||
54 | template<typename T> | |
55 | gnu_obj_2<int> gnu_obj_3<T>::data(etruscan); | |
e70d6e3f DC |
56 | |
57 | // 2002-08-16 | |
58 | // Test four. | |
59 | #include "m-static.h" | |
258093ca MC |
60 | } |
61 | ||
62 | // instantiate templates explicitly so their static members will exist | |
63 | template class __gnu_test::gnu_obj_2<int>; | |
64 | template class __gnu_test::gnu_obj_2<long>; | |
65 | template class __gnu_test::gnu_obj_3<long>; | |
66 | ||
67 | int main() | |
68 | { | |
69 | using namespace __gnu_test; | |
70 | ||
71 | gnu_obj_1 test1(egyptian, 4589); | |
72 | gnu_obj_2<long> test2(roman); | |
73 | gnu_obj_3<long> test3(greek); | |
e70d6e3f | 74 | gnu_obj_4 test4; |
258093ca | 75 | |
e70d6e3f | 76 | return 0; // breakpoint: constructs-done |
258093ca | 77 | } |