// Build don't link: // GROUPS passed old-abort // Special g++ Options: const bool FALSE = 0; const bool TRUE = 1; class ListDProto { public: ListDProto(); ListDProto(const ListDProto&); virtual ~ListDProto(); void operator=(const ListDProto&); unsigned length() const; bool empty() const; void clear(); void remove_head(); void remove_tail(); class link; class Vix { public: Vix(); friend int operator==(void *v, const Vix& x) { return v == x.item; }// ERROR - list of candidates friend int operator==(const Vix& x, void *v) { return v == x.item; }// ERROR - candidate for call friend int operator!=(void *v, const Vix& x) { return v != x.item; } friend int operator!=(const Vix& x, void *v) { return v != x.item; } friend int operator==(const Vix& x1, const Vix& x2) { return x1.owner == x2.owner && x1.item == x2.item; }// ERROR - candidate for call friend int operator!=(const Vix& x1, const Vix& x2) { return x1.owner != x2.owner || x1.item != x2.item; } bool first; bool last; protected: friend class ListDProto; Vix(const ListDProto *o, link *i); const ListDProto *owner; private: link *item; }; enum Action { NORMAL, REMOVE_CURRENT }; Vix first() const; void first(Vix& x) const; void next(Vix& x) const; void next(Vix& x, Action a = NORMAL); Vix last() const; void last(Vix& x) const; void prev(Vix& x) const; void prev(Vix& x, Action a = NORMAL); protected: struct link { link *next; link *prev; link(link *n = 0, link *p = 0); virtual ~link(); private: link(const link&); void operator=(const link&); }; unsigned count; link *list_head; link *list_tail; virtual link *copy_item(link *old_item) const = 0; void prepend(link *item); void append(link *item); void prepend(const ListDProto& proto); void append(const ListDProto& proto); void remove(link *item); link *ref(const Vix&) const; }; template class ListD: public ListDProto { public: void prepend(const T& item); void append(const T& item); const T& head() const; T& head(); void head(T& fill) const; void remove_head() { ListDProto::remove_head(); } void remove_head(T& fill); const T& tail() const; T& tail(); void tail(T& fill) const; void remove_tail() { ListDProto::remove_tail(); } void remove_tail(T& fill); class Vix: public ListDProto::Vix { public: Vix(): ListDProto::Vix() { } protected: friend class ListD; Vix(const ListDProto::Vix& x): ListDProto::Vix(x) { } }; Vix first() const { return ListDProto::first(); }; void first(Vix& x) const { ListDProto::first(x); }; void next(Vix& x, ListDProto::Action a = NORMAL) const { ListDProto::next(x, a); }// ERROR - .*// ERROR - .* Vix last() const { return ListDProto::last(); } void last(Vix& x) const { return ListDProto::last(x); } void prev(Vix& x, ListDProto::Action a = NORMAL) const { return ListDProto::prev(x, a); } protected: struct link_item: public ListDProto::link { T item; link_item(const T& i): link(0, 0), item(i) { } private: link_item(const link_item&); void operator=(const link_item&); }; public: T& operator()(const Vix& x) { link_item *li = (link_item *) ref(x); return li->item; } const T& operator()(const Vix& x) const { link_item *li = (link_item *) ref(x); return li->item; } private: ListDProto::link *copy_item(ListDProto::link *old_item) const; }; template class SetLD: private ListD { public: SetLD(); SetLD(const ListD&); void add(const T& item); void add(const ListD& other); void add(const SetLD& other); void remove(const T& item); bool contains(const T& item) const; ListD::length; ListD::empty; ListD::clear; typedef typename ListD::Vix Vix; ListD::first; ListD::next; ListD::operator(); using ListD::NORMAL; using ListD::REMOVE_CURRENT; }; extern "C" { extern void __eprintf (const char *, const char *, unsigned, const char *); } extern "C" { extern void __eprintf (const char *, const char *, unsigned, const char *); } template void ListD::prepend(const T& item) { link *newl = new link_item(item); ListDProto::prepend(newl); } template void ListD::append(const T& item) { link *newl = new link_item(item); ListDProto::append(newl); } template const T& ListD::head() const { ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 50 , "0 != list_head" ), 0) )) ; link_item *h = (link_item *) list_head; return h->item; } template T& ListD::head() { ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 59 , "0 != list_head" ), 0) )) ; link_item *h = (link_item *) list_head; return h->item; } template void ListD::head(T& fill) const { ((void) (( 0 != list_head ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 68 , "0 != list_head" ), 0) )) ; link_item *h = (link_item *) list_head; fill = h->item; } template void ListD::remove_head(T& fill) { head(fill); remove_head(); } template const T& ListD::tail() const { ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 85 , "0 != list_tail" ), 0) )) ; link_item *h = (link_item *) list_tail; return h->item; } template T& ListD::tail() { ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 94 , "0 != list_tail" ), 0) )) ; link_item *h = (link_item *) list_tail; return h->item; } template void ListD::tail(T& fill) const { ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 103 , "0 != list_tail" ), 0) )) ; link_item *h = (link_item *) list_tail; fill = h->item; } template void ListD::remove_tail(T& fill) { ((void) (( 0 != list_tail ) ? 0 : (__eprintf ("%s:%u: failed assertion `%s'\n", "/home/wbaker/work/include/templates/ListD.body.h" , 112 , "0 != list_tail" ), 0) )) ; link_item *h = (link_item *) list_tail; fill = h->item; } template ListDProto::link * ListD::copy_item(ListDProto::link *old) const { link_item *old_item = (link_item *) old; link_item *new_item = new link_item(old_item->item); return new_item; } template SetLD::SetLD(): ListD() { } template SetLD::SetLD(const ListD& other): ListD(other) { } template void SetLD::add(const T& item) { if ( ! contains(item) ) append(item); } template void SetLD::add(const ListD& other) { typename ListD::Vix x; for (first(x); 0 != x; next(x)) add(other(x)); } template void SetLD::add(const SetLD& other) { const ListD& lother = other; add(lother); } template void SetLD::remove(const T& item) { typename ListD::Action a = NORMAL; Vix x; for (first(x); 0 != x && REMOVE_CURRENT != a; next(x, a)) a = operator()(x) == item ? REMOVE_CURRENT: NORMAL;// ERROR - .* } template bool SetLD::contains(const T& item) const { Vix x; for (first(x); 0 != x; next(x)) { if (operator()(x) == item)// ERROR - .* return TRUE; } return FALSE; } template int operator==(const SetLD& a, const SetLD& b) { if (a.length() != b.length()) return FALSE; typename SetLD::Vix x; for (a.first(x); 0 != x; a.next(x)) { if ( ! b.contains(a(x)) ) return FALSE; } for (b.first(x); 0 != x; b.next(x)) { if ( ! a.contains(b(x)) ) return FALSE; } return TRUE; } template int operator!=(const SetLD& a, const SetLD& b) { return ! (a == b); } template int operator<=(const SetLD& a, const SetLD& b) { if (a.length() > b.length()) return FALSE; typename SetLD::Vix x; for (x=a.first(); 0 != x; a.next(x)) { if ( ! b.contains(a(x)) ) return FALSE; } return TRUE; } template int operator<(const SetLD& a, const SetLD& b) { if (a.length() >= b.length()) return FALSE; return a <= b; } template int operator>(const SetLD& a, const SetLD& b) { return ! (a <= b); } template int operator>=(const SetLD& a, const SetLD& b) { return ! (a < b); } class String { }; class IcaseString: public String { }; class SetLD< IcaseString >: public SetLD< String > { public: SetLD (): SetLD< String >() { }; SetLD (const ListD< IcaseString >& other): SetLD< String >() { ListD< IcaseString >::Vix x; for (other.first(x); 0 != x; other.next(x)) add(other(x)); }; SetLD (const SetLD & other): SetLD< String >(other) { }; const IcaseString & operator()(const Vix& x) const { return ( IcaseString &) SetLD< String >::operator()(x); } }; typedef SetLD< String > SetLD_String_IcaseString_old_tmp99; typedef SetLD< IcaseString > SetLD_String_IcaseString_new_tmp99; inline int operator== (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) {// ERROR - candidate for call const SetLD_String_IcaseString_old_tmp99& oa = a; const SetLD_String_IcaseString_old_tmp99& ob = b; return operator== (oa, ob); } inline int operator!= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) { const SetLD_String_IcaseString_old_tmp99& oa = a; const SetLD_String_IcaseString_old_tmp99& ob = b; return operator!= (oa, ob); } inline int operator< (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) { const SetLD_String_IcaseString_old_tmp99& oa = a; const SetLD_String_IcaseString_old_tmp99& ob = b; return operator< (oa, ob); } inline int operator<= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) { const SetLD_String_IcaseString_old_tmp99& oa = a; const SetLD_String_IcaseString_old_tmp99& ob = b; return operator<= (oa, ob); } inline int operator> (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) { const SetLD_String_IcaseString_old_tmp99& oa = a; const SetLD_String_IcaseString_old_tmp99& ob = b; return operator> (oa, ob); } inline int operator>= (const SetLD_String_IcaseString_new_tmp99& a, const SetLD_String_IcaseString_new_tmp99& b) { const SetLD_String_IcaseString_old_tmp99& oa = a; const SetLD_String_IcaseString_old_tmp99& ob = b; return operator>= (oa, ob); } ; typedef SetLD SLDiS; static void nop(int i) { SetLD x, y; nop(x == y); nop(x != y); nop(x < y); nop(x <= y); nop(x > y); nop(x >= y); } template class SetLD;