template<class K, class V> class Map { friend class Mapiter<K,V>; Link<K,V>* head; Link<K,V>* current; V def_val; K def_key; int sz; static K kdef(); // default K value static V vdef(); // default V value void find(const K&); void init() { sz = 0; head = 0; current = 0; } public: Map() : def_key(kdef()), def_val(vdef()) { init(); } Map(const K& k, const V& d) : def_key(k), def_val(d) { init(); } ~Map() { delete head; } // delete all links recursively Map(const Map&); Map& operator= (const Map&); V& operator[] (const K&); int size() const { return sz; } void clear() { delete head; init(); } void remove(const K& k); // iteration functions: Mapiter<K,V> element(const K& k) { (void) operator[](k); // move current to k return Mapiter<K,V>(this,current); } Mapiter<K,V> first() { return Mapiter<K,V>(this,head); } Mapiter<K,V> last(); }; template<class K, class V> K Map<K,V>::kdef() { static K k; return k; } template<class K, class V> V Map<K,V>::vdef() { static V v; return v; }
base_iterator(const base_iterator&); base_iterator& operator=(const base_iterator&);replace base_iterator::base_iterator() definition with:
base_iterator::base_iterator(const Type_info* bb, int direct) { i = 0; if (direct) { // use list of direct bases b = bb; alloc = 0; return; } // create list of all bases: // int n = number of bases b = new (Type_info*)[n+1]; alloc = 1; // put bases into b }
#define ptr_cast(T,p) \ (T::info().get_type_info()->can_cast((p)) ? (T*)(p) : 0) #define ref_cast(T,r) \ (T::info().get_type_info()->can_cast((r)) ? 0 : \ throw Bad_cast(T::info().get_type_info()->name()), (T&)(r))