[ARM] PR target/49423
[official-gcc.git] / libvtv / testsuite / libvtv.cc / template-list-iostream.cc
blob06ec3b01e102eb9635e36fefcd4bf8c3bba9e584
1 // { dg-do run }
3 #include <assert.h>
4 #include <iostream>
5 #include <fstream>
7 using std::ofstream;
8 using std::ifstream;
9 using std::ios;
11 extern "C" int printf(const char *, ...);
13 class Subscriptor
15 public:
17 Subscriptor() : counter(1) {}
19 virtual ~Subscriptor()
21 counter--;
22 assert(counter == 0);
25 private:
26 mutable int counter;
29 template <int dim> struct Function
31 Function(int i): value(dim + i) {}
32 int value;
35 template <int dim> struct Triangulation
40 template <int dim> struct Exercise_2_3
42 enum { DIM = dim };
45 template <int dim>
46 struct SetUpBase : public Subscriptor
48 virtual
49 const Function<dim> get_boundary_values () const = 0;
51 virtual
52 const Function<dim> get_right_hand_side () const = 0;
54 // virtual
55 // void create_coarse_grid (Triangulation<dim> &coarse_grid) const = 0;
58 template <class Traits, int dim>
59 struct SetUp : public SetUpBase<dim>
61 SetUp () {};
63 virtual
64 const Function<dim> get_boundary_values () const
65 { return Function<dim>(Traits::DIM); }
67 virtual
68 const Function<dim> get_right_hand_side () const
69 { return Function<dim>(Traits::DIM); }
71 // virtual
72 // void create_coarse_grid (Triangulation<dim> &coarse_grid) const;
74 // static const typename Traits::BoundaryValues boundary_values;
75 // static const typename Traits::RightHandSide right_hand_side;
79 void myread(std::istream * in)
81 char input_str[50] = "\0";
82 if (in->good())
83 (*in) >> input_str;
84 std::cout << input_str << std::endl;
85 delete in;
90 int main()
94 SetUp<Exercise_2_3<1000>, 2> s1a;
95 SetUp<Exercise_2_3<2000>, 1> s2;
96 SetUp<Exercise_2_3<2000>, 2> s2a;
97 return s1->get_boundary_values().value + s1a.get_boundary_values().value +
98 s2.get_boundary_values().value + s2a.get_boundary_values().value +
99 s1->get_right_hand_side().value + s1a.get_right_hand_side().value +
100 s2.get_right_hand_side().value + s2a.get_right_hand_side().value;
103 SetUp<Exercise_2_3<1000>, 1> * s1 = new SetUp<Exercise_2_3<1000>, 1>();
105 printf("%d\n", s1->get_boundary_values().value);
107 ifstream * infile = new ifstream("./template-list-iostream.cc");
109 myread(infile);
111 ofstream * outfile = new ofstream("/tmp/xxx.txt");
113 if (outfile->good())
114 (*outfile) << "hello there" << std::endl;
115 std::cerr << "Reached End" << std::endl;
117 delete outfile;
119 return 0;