This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] PR libstdc++/79206 check string_view sizes in operator==
- From: Ville Voutilainen <ville dot voutilainen at gmail dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: "libstdc++" <libstdc++ at gcc dot gnu dot org>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 24 Jan 2017 14:54:31 +0200
- Subject: Re: [PATCH] PR libstdc++/79206 check string_view sizes in operator==
- Authentication-results: sourceware.org; auth=none
- References: <20170124120542.GA10349@redhat.com>
On 24 January 2017 at 14:05, Jonathan Wakely <jwakely@redhat.com> wrote:
> I've just committed this, and then noticed that we don't do the same
> optimization for basic_string unless the char_type is char. Presumably
> this is so that we do call basic_string::compare() and so call any
> user-defined traits_type::eq() function (which is observable). I don't
> think that's necessary, because the standard says operator== on
> strings returns the result of lhs.compare(rhs) == 0, not that it's
> "Equivalent to" such a call. As long as we give the right answer, I
> don't think we need to make an explicit call to
> basic_string::compare(). So maybe we want this for basic_string too.
We do want it for basic_string as well, I think. And while I doubt
your interpretation
of the standard is pedantically correct, I also think that the
standard is broken if it
doesn't allow this optimization, and the standard should be fixed in that case.