gcc config
[prop.git] / prop-src / T10.pcc
blobc2dfcfd0b93238c950b7a39b4743c2944a328c99
1 #include <iostream>
3 struct IA { void hasIA() {} };
4 struct IB { void hasIB() {} };
5 struct IC { void hasIC() {} };
6 struct ID { void hasID() {} };
7 struct IE { void hasIE() {} };
8 struct I1 { void hasI1() {} };
9 struct I2 { void hasI2() {} };
10 struct I3 { void hasI3() {} };
13 datatype T = A() : IA with { void get_A(); }
14            | B() : IB with { void get_B(); }
15            | C() : IC with { void get_C(); }
16            | D() : ID with { void get_D(); }
17 public:
19    void test_T() {}
22 datatype T2 : IE = E() with { void get_E(); } 
23 public:
25    void test_T2() {}
29 refine T : I1 :: collectable { virtual std::ostream& print(std::ostream&) = 0; }
30 and    A, B, C, D : I2 { std::ostream& print(std::ostream&); }
31 and    T2 : I3 :: collectable { virtual std::ostream& print(std::ostream&); }
34 instantiate datatype T, T2;
36 void classof A::get_A() { hasIA(); hasI1(); hasI2(); }
37 void classof B::get_B() { hasIB(); hasI1(); hasI2(); }
38 void classof C::get_C() { hasIC(); hasI1(); hasI2(); }
39 void classof D::get_D() { hasID(); hasI1(); hasI2(); }
40 void classof E::get_E() { hasIE(); hasI3(); }
42 std::ostream& classof A::print(std::ostream& s) { return s << "A"; }
43 std::ostream& classof B::print(std::ostream& s) { return s << "B"; }
44 std::ostream& classof C::print(std::ostream& s) { return s << "C"; }
45 std::ostream& classof D::print(std::ostream& s) { return s << "D"; }
46 std::ostream& classof E::print(std::ostream& s) { return s << "E"; }
48 int main()
49 {  T x = A();
50    x->test_T();
51    x->print(cout) << '\n';
52    T2 y = E();
53    y->test_T2();
54    y->print(cout) << '\n';
55    return 0;