This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: RFC: change in std::type_info's equality operator
- From: Paolo Carlini <pcarlini at suse dot de>
- To: Matt Austern <austern at apple dot com>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>,gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Wed, 04 Feb 2004 19:20:28 +0100
- Subject: Re: RFC: change in std::type_info's equality operator
- References: <B31A11EE-573B-11D8-99B0-000A95AA5E5E@apple.com>
Matt Austern wrote:
I sent out a message yesterday suggesting a change in
std::type_info::operator==. I didn't get a response, possibly because
my suggestion was buried in a message that largely talked about other
things. (I began with a detailed discussion leading up to why the
change would be useful for certain purposes.) So let's try again, and
this time I'll begin at the beginning.
Sorry about my personal lack of attention or lack of real understanding,
I would say.
Right now, depending on whether or not a certain macro is set when
libstdc++ is built, t1==t2 is equivalent to one of these two expressions:
(1) t1.__name == t2.__name, where __name is the address of the string
representing the type's name.
(2) t1.__name == t2.__name || strcmp(t1.__name, t2.__name) == 0.
The library uses version (1) iff the compiler defines __GXX_WEAK__ to
be true.
My proposal: change the library so it unconditionally uses version 2.
That is, always fall back to string comparison if the address comparison
Now it's much more clear (to me, at least).
I have double checked the standard ;) and everything seems ok with your
proposal. Indeed, we are already using an identical strategy for
locale::operator== (perhaps we could improve that implementation, but
this is another story ;).
Let's wait for other opinions, though.
Paolo.