]> git.ipfire.org Git - thirdparty/gcc.git/blob - libvtv/testsuite/template-list.cc
Commit the vtable verification feature. This feature is designed to
[thirdparty/gcc.git] / libvtv / testsuite / template-list.cc
1 #include <assert.h>
2
3 extern "C" int printf(const char *, ...);
4
5 class Subscriptor
6 {
7 public:
8
9 Subscriptor() : counter(1) {}
10
11 virtual ~Subscriptor()
12 {
13 counter--;
14 assert(counter == 0);
15 }
16
17 private:
18 mutable int counter;
19 };
20
21 template <int dim> struct Function
22 {
23 Function(int i): value(dim + i) {}
24 int value;
25 };
26
27 template <int dim> struct Triangulation
28 {
29
30 };
31
32 template <int dim> struct Exercise_2_3
33 {
34 enum { DIM = dim };
35 };
36
37 template <int dim>
38 struct SetUpBase : public Subscriptor
39 {
40 virtual
41 const Function<dim> get_boundary_values () const = 0;
42
43 virtual
44 const Function<dim> get_right_hand_side () const = 0;
45
46 // virtual
47 // void create_coarse_grid (Triangulation<dim> &coarse_grid) const = 0;
48 };
49
50 template <class Traits, int dim>
51 struct SetUp : public SetUpBase<dim>
52 {
53 SetUp () {};
54
55 virtual
56 const Function<dim> get_boundary_values () const
57 { return Function<dim>(Traits::DIM); }
58
59 virtual
60 const Function<dim> get_right_hand_side () const
61 { return Function<dim>(Traits::DIM); }
62
63 // virtual
64 // void create_coarse_grid (Triangulation<dim> &coarse_grid) const;
65
66 // static const typename Traits::BoundaryValues boundary_values;
67 // static const typename Traits::RightHandSide right_hand_side;
68 };
69
70
71 int main()
72 {
73 /*
74
75 SetUp<Exercise_2_3<1000>, 2> s1a;
76 SetUp<Exercise_2_3<2000>, 1> s2;
77 SetUp<Exercise_2_3<2000>, 2> s2a;
78 return s1->get_boundary_values().value + s1a.get_boundary_values().value +
79 s2.get_boundary_values().value + s2a.get_boundary_values().value +
80 s1->get_right_hand_side().value + s1a.get_right_hand_side().value +
81 s2.get_right_hand_side().value + s2a.get_right_hand_side().value;
82 */
83 #ifndef NFAIL
84 SetUp<Exercise_2_3<1000>, 1> * s1 = new SetUp<Exercise_2_3<1000>, 1>();
85 printf("%d\n", s1->get_boundary_values().value);
86 return 0;
87 #else
88 SetUp<Exercise_2_3<1000>, 1> s1;
89 printf("%d\n", s1.get_boundary_values().value);
90 return 0;
91 #endif
92 }