1typedef __SIZE_TYPE__ size_t; 2template<typename _Iterator, typename _Container> class __normal_iterator { 3public: 4 const _Iterator& base() const; 5}; 6template<typename _BI1, typename _BI2> inline 7void copy_backward(_BI1 __first, _BI1 __last, _BI2 __result) { 8 while (__first != __last) *--__result = *--__last; 9} 10template<typename _Tp> struct _Vector_base { 11 struct _Vector_impl { _Tp* _M_finish; }; 12 _Vector_impl _M_impl; 13}; 14template<typename _Tp > class vector : protected _Vector_base<_Tp> { 15 typedef vector<_Tp> vector_type; 16 typedef _Tp * pointer; 17 typedef _Tp & reference; 18 typedef __normal_iterator<pointer, vector_type> iterator; 19 typedef size_t size_type; 20public: 21 iterator end(); 22 void resize(size_type __new_size) { insert(end(), __new_size); } 23 reference operator[](size_type __n); 24 void insert(iterator __position, size_type __n) 25 { 26 pointer __old_finish(this->_M_impl._M_finish); 27 copy_backward(__position.base(), __old_finish - __n, __old_finish); 28 } 29}; 30struct A { 31 virtual ~A (); 32 void incRef (); 33 void decRef (); 34}; 35struct C : public A { 36 static C *alloc (); 37}; 38template <class T> struct B { 39 B () : ptr (T::alloc ()) { } 40 B (T *a_ptr) : ptr (a_ptr) { } 41 ~B () { decRef (); } 42 B& operator= (const B<T>& a) { if (a.get () != this->get ()) { decRef (); 43incRef (); } } 44 template<class U> operator B<U> () const { return B<U> (ptr); } 45 T* operator-> () const { } 46 T* get () const { return ptr; } 47 void decRef () const { if (ptr != 0) ptr->decRef (); } 48 void incRef () const { if (ptr != 0) ptr->incRef (); } 49 T *ptr; 50}; 51struct D : public C { 52 template <class T> inline void foo (const B<T> & x) { d.resize (1); d[0] = x; 53} 54 vector<B <C> > d; 55}; 56struct E : public C { 57 static E *alloc (); 58}; 59struct F : public D { 60 static F *alloc (); 61}; 62void foo (vector<B<D> > & x) { 63 for (int i = 0; i < 2; ++i) 64 { 65 B<F> l; 66 B<E> m; 67 l->foo (m); 68 } 69} 70