This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
RFC: change in std::type_info's equality operator
- From: Matt Austern <austern at apple dot com>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>, gcc mailing list <gcc at gcc dot gnu dot org>
- Date: Wed, 4 Feb 2004 09:58:12 -0800
- Subject: RFC: change in std::type_info's equality operator
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.
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
The disadvantage: it hurts the performance of anything that uses
typeinfo comparison where negative comparisons are common. (I suspect
that nothing performance-critical uses type_info::operator==. I'll
drop this proposal if someone shows me otherwise.) The advantage: I
would like to introduce a feature that has the effect, if users specify
a particular command line option, of disabling merging of typeinfo
names across shared libraries. This mode will not be the default. But
the problem is that I can't introduce it at all if libstdc++ assumes
that names will always be merged.
--Matt