🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++
Article #149

problems with genclass

#149
From: Doug Lea
Date: Thu, 28 Sep 1989 13:01
32 lines
1527 bytes
> We've been unhappy with the classes generated by genclass because each
> type needs to be separately generated, including the entire
> ... 
 
First, please use bug-lib-g++ for libg++-related questions. (There is
no info-lib-g++, just use the bug list.)

Possibly the best solution in your case would be to

    1) have all your classes be derived from a common base, that
        includes a virtual int compare(Base* b);

    2) Have all your containers be of Base*'s (suitably typedef'ed)

    3) Edit the CMP(a, b) macro to call a->compare.

And/Or similarly for the EQ macros, etc.


This gets you heterogenous containers. If you want homogenous
containers, then you probably want to live with multiple implementations.

The main disadvantage of the current container library is that you can't
readily set things up so that you can have subclasses of Set, each of
which shares the basic Set code but operates on pointers of an
*unrelated* different type.

I don't think that full C++ support for generics will happen in the
near future.

-Doug
Technical Details
Message-ID: <8909281301.AA20359@g.oswego.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!G.OSWEGO.EDU!dl
References: <RIEDL.89Sep26175140@medusa.cs.purdue.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!G.OSWEGO.EDU!dl
From: dl@G.OSWEGO.EDU (Doug Lea)
Newsgroups: gnu.g++
Subject: problems with genclass
Message-ID: <8909281301.AA20359@g.oswego.edu>
Date: 28 Sep 89 13:01:07 GMT
References: <RIEDL.89Sep26175140@medusa.cs.purdue.EDU>
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: dl@oswego.oswego.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 32