RFC: change in std::type_info's equality operator
Paolo Carlini
pcarlini@suse.de
Wed Feb 4 18:18:00 GMT 2004
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.
More information about the Gcc
mailing list