From -7531805890486291168
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,5cc0e5689db82f7b
X-Google-Attributes: gidf78e5,public
From: jkanze@otelo.ibmmail.com
Subject: Re: Is type_info object static or temporary?
Date: 1998/06/08
Message-ID: <6lgcsi$fb5$1@nnrp1.dejanews.com>#1/1
X-Deja-AN: 360692426
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <356D82DA.36025D97@matfys.lth.se> <6kl3ar$npi$1@shell7.ba.best.com> <35727d32.0@210.134.196.10> <oryavgswwj.fsf@zecarneiro.lsd.dcc.unicamp.br> <3578C2EA.18AA8308@ix.netcom.com>
Originator: clamage@taumet
X-NNTP-Posting-Host: 195.75.80.129
X-UID: 0000000001
X-Status: $$$T
X-Http-User-Agent: Mozilla/4.03 [de] (WinNT; I)
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Mon Jun 08 10:02:59 1998 GMT
Newsgroups: comp.std.c++


In article <3578C2EA.18AA8308@ix.netcom.com>,
  "Paul D. DeRocco" <pderocco@ix.netcom.com> wrote:
>
> Alexandre Oliva wrote:
> >
> > type_infos, OTOH, have a direct correspondence with
> > actual types
>
> Is that entirely true? Obviously, two different types will never return
> the same type_info, but isn't it expressly legal for the same type to
> return different typeinfo objects at different times, as long as they
> compare equal with operator==?
>
> If so, I think this is in order to accommodate dumb linkers that have no
> mechanism for ensuring that only a single copy of a type_info will be
> kept when multiple modules introduce it. It's too bad, because if the
> linker could be counted on to be this smart, then type_infos would
> become atoms, and operator== could be implemented as a simple address
> comparison (as could operator<). This would vastly speed up programs
> that use type_infos as map keys, for instance--especially if the
> alternative is to do a strcmp on the name strings, which is what Borland
> does. Incidentally, I don't really understand why Borland does that,
> since its linker is smart enough to ensure the uniqueness of type_info
> objects.

Using a strcmp on the results of name() is not guaranteed to work, as
far as I can tell.  There is no guarantee that two different types
have different names.  For map, the correct function to use is below.
And an implementation which does ensure that there is only a single
instance for each type can legally implement below as a comparison
of the this pointers, I believe.

Of course, if you want a hash_map (as I usually do), then you're out
of luck.

--
James Kanze    +33 (0)1 39 23 84 71    mailto: kanze@gabi-soft.fr
        +49 (0)69 66 45 33 10    mailto: jkanze@otelo.ibmmail.com
GABI Software, 22 rue Jacques-Lemercier, 78000 Versailles, France
Conseils en informatique orient�e objet --
              -- Beratung in objektorientierter Datenverarbeitung

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




