https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82891

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Tony E Lewis from comment #4)
> Are these arguments unpersuasive?

IMHO yes.

Comparison that only work with non-const objects are just bad comparison
functions. They are unusable with maps and sets, because in a const-qualified
member function they might be passed const arguments. They risk modifying their
arguments, which leads to undefined behaviour. In your specific example, taking
the arguments by reference might be less efficient than taking ints by value,
so pessimizes the code.

Requiring comparison objects to be usable as-const and with-const (i.e. when
the comparison function object itself is const, and when the arguments are
const) leads to fewer surprises, and is not especially difficult.

The C++ working draft has been changed to make this program undefined, and I'm
not inclined to make it Just Work.

Reply via email to