On 24 January 2017 at 14:05, Jonathan Wakely <jwak...@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.