|
|
1.1 ! root 1: #include "check.h" ! 2: ! 3: /* Test nested instantiations, when the instantiations are via base classes */ ! 4: /* the test should compile and run without any errors */ ! 5: ! 6: template <class p1, class p2> class b { ! 7: public: ! 8: b(p1, p2) ; ! 9: p1 x ; ! 10: p2 y ; ! 11: void foo() ; ! 12: } ; ! 13: ! 14: template <class pd1, class pd2> class d : public b<pd1, pd2> { ! 15: public: ! 16: d(pd1, pd2) ; ! 17: pd1 *i ; ! 18: int check_i(pd1 test) ; ! 19: int check_x(pd1 test) ; ! 20: int check_y(pd2 test) ; ! 21: } ; ! 22: ! 23: ! 24: // Check access from within a member function ! 25: template <class pd1, class pd2>int d<pd1,pd2>::check_i(pd1 test) { ! 26: return (*i == test) ; ! 27: } ! 28: ! 29: template <class pd1, class pd2> d<pd1,pd2>::d(pd1 p1, pd2 p2) : (p1, p2) { ! 30: } ! 31: ! 32: template <class pd1, class pd2> int d<pd1,pd2>::check_x(pd1 test) { ! 33: return (x == test) ; ! 34: } ! 35: ! 36: ! 37: template <class pd1, class pd2> int d<pd1,pd2>::check_y(pd2 test) { ! 38: return (y == test) ; ! 39: } ! 40: ! 41: template <class p1, class p2> b<p1,p2>::b(p1, p2 ) { ! 42: } ! 43: ! 44: ! 45: ! 46: typedef char *pc ; ! 47: typedef int *pi ; ! 48: ! 49: ! 50: ! 51: main () { ! 52: start_test(__FILE__) ; ! 53: ! 54: { ! 55: int i ; char c ; ! 56: d<int, pc> v1(1, &c) ; ! 57: ! 58: ! 59: v1.i = & i ; ! 60: v1.x = i ; ! 61: v1.y = & c ; ! 62: ! 63: check (v1.i == & i) ; ! 64: check (v1.x == i) ; ! 65: check(v1.y == & c) ; ! 66: ! 67: check (v1.check_i (i)) ; ! 68: check (v1.check_x (i)) ; ! 69: check (v1.check_y (&c)) ; ! 70: ! 71: } ! 72: ! 73: { ! 74: int i = 0 ; char c, *cc ; ! 75: d<pc, int> v1(cc, i) ; ! 76: ! 77: ! 78: v1.i = & cc ; ! 79: v1.x = &c ; ! 80: v1.y = i ; ! 81: ! 82: check (v1.i == &cc) ; ! 83: check (v1.x == &c) ; ! 84: check(v1.y == i) ; ! 85: ! 86: check (v1.check_i ( cc)) ; ! 87: check (v1.check_x (&c)) ; ! 88: check (v1.check_y (i)) ; ! 89: ! 90: } ! 91: ! 92: ! 93: ! 94: end_test() ; ! 95: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.