// { dg-do run } #include #include #include using std::ofstream; using std::ifstream; using std::ios; extern "C" int printf(const char *, ...); class Subscriptor { public: Subscriptor() : counter(1) {} virtual ~Subscriptor() { counter--; assert(counter == 0); } private: mutable int counter; }; template struct Function { Function(int i): value(dim + i) {} int value; }; template struct Triangulation { }; template struct Exercise_2_3 { enum { DIM = dim }; }; template struct SetUpBase : public Subscriptor { virtual const Function get_boundary_values () const = 0; virtual const Function get_right_hand_side () const = 0; // virtual // void create_coarse_grid (Triangulation &coarse_grid) const = 0; }; template struct SetUp : public SetUpBase { SetUp () {}; virtual const Function get_boundary_values () const { return Function(Traits::DIM); } virtual const Function get_right_hand_side () const { return Function(Traits::DIM); } // virtual // void create_coarse_grid (Triangulation &coarse_grid) const; // static const typename Traits::BoundaryValues boundary_values; // static const typename Traits::RightHandSide right_hand_side; }; void myread(std::istream * in) { char input_str[50] = "\0"; if (in->good()) (*in) >> input_str; std::cout << input_str << std::endl; delete in; } int main() { /* SetUp, 2> s1a; SetUp, 1> s2; SetUp, 2> s2a; return s1->get_boundary_values().value + s1a.get_boundary_values().value + s2.get_boundary_values().value + s2a.get_boundary_values().value + s1->get_right_hand_side().value + s1a.get_right_hand_side().value + s2.get_right_hand_side().value + s2a.get_right_hand_side().value; */ SetUp, 1> * s1 = new SetUp, 1>(); printf("%d\n", s1->get_boundary_values().value); ifstream * infile = new ifstream("./template-list-iostream.cc"); myread(infile); ofstream * outfile = new ofstream("/tmp/xxx.txt"); if (outfile->good()) (*outfile) << "hello there" << std::endl; std::cerr << "Reached End" << std::endl; delete outfile; return 0; }