2015-02-06 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / libvtv / testsuite / libvtv.cc / template-list.cc
blobaeb2db9e52671e2cf3a46d083f4cf60da6a6031a
1 // { dg-do run }
3 #include <assert.h>
5 extern "C" int printf(const char *, ...);
7 class Subscriptor
9 public:
11 Subscriptor() : counter(1) {}
13 virtual ~Subscriptor()
15 counter--;
16 assert(counter == 0);
19 private:
20 mutable int counter;
23 template <int dim> struct Function
25 Function(int i): value(dim + i) {}
26 int value;
29 template <int dim> struct Triangulation
34 template <int dim> struct Exercise_2_3
36 enum { DIM = dim };
39 template <int dim>
40 struct SetUpBase : public Subscriptor
42 virtual
43 const Function<dim> get_boundary_values () const = 0;
45 virtual
46 const Function<dim> get_right_hand_side () const = 0;
48 // virtual
49 // void create_coarse_grid (Triangulation<dim> &coarse_grid) const = 0;
52 template <class Traits, int dim>
53 struct SetUp : public SetUpBase<dim>
55 SetUp () {};
57 virtual
58 const Function<dim> get_boundary_values () const
59 { return Function<dim>(Traits::DIM); }
61 virtual
62 const Function<dim> get_right_hand_side () const
63 { return Function<dim>(Traits::DIM); }
65 // virtual
66 // void create_coarse_grid (Triangulation<dim> &coarse_grid) const;
68 // static const typename Traits::BoundaryValues boundary_values;
69 // static const typename Traits::RightHandSide right_hand_side;
73 int main()
77 SetUp<Exercise_2_3<1000>, 2> s1a;
78 SetUp<Exercise_2_3<2000>, 1> s2;
79 SetUp<Exercise_2_3<2000>, 2> s2a;
80 return s1->get_boundary_values().value + s1a.get_boundary_values().value +
81 s2.get_boundary_values().value + s2a.get_boundary_values().value +
82 s1->get_right_hand_side().value + s1a.get_right_hand_side().value +
83 s2.get_right_hand_side().value + s2a.get_right_hand_side().value;
85 #ifndef NFAIL
86 SetUp<Exercise_2_3<1000>, 1> * s1 = new SetUp<Exercise_2_3<1000>, 1>();
87 printf("%d\n", s1->get_boundary_values().value);
88 return 0;
89 #else
90 SetUp<Exercise_2_3<1000>, 1> s1;
91 printf("%d\n", s1.get_boundary_values().value);
92 return 0;
93 #endif