]> git.ipfire.org Git - thirdparty/gcc.git/blob - libvtv/testsuite/template-list-iostream.cc
Commit the vtable verification feature. This feature is designed to
[thirdparty/gcc.git] / libvtv / testsuite / template-list-iostream.cc
1 #include <assert.h>
2 #include <iostream>
3 #include <fstream>
4
5 using std::ofstream;
6 using std::ifstream;
7 using std::ios;
8
9 extern "C" int printf(const char *, ...);
10
11 class Subscriptor
12 {
13 public:
14
15 Subscriptor() : counter(1) {}
16
17 virtual ~Subscriptor()
18 {
19 counter--;
20 assert(counter == 0);
21 }
22
23 private:
24 mutable int counter;
25 };
26
27 template <int dim> struct Function
28 {
29 Function(int i): value(dim + i) {}
30 int value;
31 };
32
33 template <int dim> struct Triangulation
34 {
35
36 };
37
38 template <int dim> struct Exercise_2_3
39 {
40 enum { DIM = dim };
41 };
42
43 template <int dim>
44 struct SetUpBase : public Subscriptor
45 {
46 virtual
47 const Function<dim> get_boundary_values () const = 0;
48
49 virtual
50 const Function<dim> get_right_hand_side () const = 0;
51
52 // virtual
53 // void create_coarse_grid (Triangulation<dim> &coarse_grid) const = 0;
54 };
55
56 template <class Traits, int dim>
57 struct SetUp : public SetUpBase<dim>
58 {
59 SetUp () {};
60
61 virtual
62 const Function<dim> get_boundary_values () const
63 { return Function<dim>(Traits::DIM); }
64
65 virtual
66 const Function<dim> get_right_hand_side () const
67 { return Function<dim>(Traits::DIM); }
68
69 // virtual
70 // void create_coarse_grid (Triangulation<dim> &coarse_grid) const;
71
72 // static const typename Traits::BoundaryValues boundary_values;
73 // static const typename Traits::RightHandSide right_hand_side;
74 };
75
76
77 void myread(std::istream * in)
78 {
79 char input_str[50] = "\0";
80 if (in->good())
81 (*in) >> input_str;
82 std::cout << input_str << std::endl;
83 delete in;
84 }
85
86
87
88 int main()
89 {
90 /*
91
92 SetUp<Exercise_2_3<1000>, 2> s1a;
93 SetUp<Exercise_2_3<2000>, 1> s2;
94 SetUp<Exercise_2_3<2000>, 2> s2a;
95 return s1->get_boundary_values().value + s1a.get_boundary_values().value +
96 s2.get_boundary_values().value + s2a.get_boundary_values().value +
97 s1->get_right_hand_side().value + s1a.get_right_hand_side().value +
98 s2.get_right_hand_side().value + s2a.get_right_hand_side().value;
99 */
100
101 SetUp<Exercise_2_3<1000>, 1> * s1 = new SetUp<Exercise_2_3<1000>, 1>();
102
103 printf("%d\n", s1->get_boundary_values().value);
104
105 ifstream * infile = new ifstream("./template-list-iostream.cc");
106
107 myread(infile);
108
109 ofstream * outfile = new ofstream("/tmp/xxx.txt");
110
111 if (outfile->good())
112 (*outfile) << "hello there" << std::endl;
113 std::cerr << "Reached End" << std::endl;
114
115 delete outfile;
116
117 return 0;
118 }