|
|
1.1 ! root 1: /* Test nested instantiations in the presence of multiple base classes */ ! 2: ! 3: ! 4: template <class p1, class p2> class b1 { ! 5: public: ! 6: p1 x1 ; ! 7: p2 y1 ; ! 8: void foo() ; ! 9: } ; ! 10: ! 11: ! 12: template <class p1, class p2> class c { ! 13: public: ! 14: p1 x2 ; ! 15: p2 y2 ; ! 16: void foo() ; ! 17: } ; ! 18: ! 19: ! 20: ! 21: class c_arg { ! 22: public: ! 23: int p ; ! 24: int q ; ! 25: inline foo (int i) { return (i == p); } ; ! 26: c_arg() ; ! 27: } ; ! 28: ! 29: c_arg::c_arg() { ! 30: p = 1 ; ! 31: q = 2 ; ! 32: } ; ! 33: ! 34: ! 35: int error = 0 ; ! 36: ! 37: #define check(p) if (!(p))printf("\nerror(%d): test failed at line %d",++error, __LINE__) ! 38: ! 39: ! 40: typedef char *pc ; ! 41: typedef int *pi ; ! 42: ! 43: extern "C" void printf(...) ; ! 44: ! 45: extern "C" void exit(int) ; ! 46: ! 47: void end_test(int error) ! 48: { ! 49: printf ("\n*End Testing %s", __FILE__) ; ! 50: if (error) ! 51: printf (" *** %d errors ***\n", error) ; ! 52: else printf (" no errors detected\n") ; ! 53: ! 54: exit(error) ; ! 55: } ! 56: ! 57: ! 58: main () { ! 59: printf ("\n*Begin Testing %s\n", __FILE__) ; ! 60: c<int, c_arg> v1 ; ! 61: check (v1.y2.p == 1) ; ! 62: check (v1.y2.q == 2) ; ! 63: check (v1.y2.foo(1)) ; ! 64: ! 65: end_test(error) ; ! 66: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.