Topic: name() isn't a hash function (Was: typeid().name syntax)
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1998/11/17 Raw View
Bill Wade wrote:
> Valentin Bonnard wrote in message <364A250D.5E9E@pratique.fr>...
> >David R Tribble wrote:
> >
> >> But it seems to me that in order to make type_info::name()
> >> behave in the most reasonable fashion, typeid() ought to return a
> >> unique string for every type in the program.
> >
> >But why ? What's the point ?
> I presume that "before()" is present to allow types to be used as keys in
> maps or sets. Unique strings would allow types to be used as keys in
> hash_maps.
You can perfectly do that today: create a map from typeinfo
to hash codes. The hash codes can be generated with a counter
from 0 to the number of typeinfo used in your system.
No, I am jocking of course. But if you want a hash code
function, don't call it name, call it hash or something
like that.
name is the name, is one format or another.
When trying to define typeinfo::name(), don't give
a resonnable definition for typeinfo::hash() !
--
Valentin Bonnard mailto:bonnardv@pratique.fr
info about C++/a propos du C++: http://pages.pratique.fr/~bonnardv/
[ 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 ]