Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2023-02-20 23:50:25


On 2/21/23 02:01, Steven Robbins via Boost wrote:
> On Monday, February 20, 2023 4:45:33 P.M. CST Andrey Semashev via Boost wrote:
>> On 2/21/23 01:00, Gavin Lambert via Boost wrote:
>>> On 21/02/2023 00:30, Andrey Semashev wrote:
>>>> I think you're missing the point that operator== isn't always used to
>>>> implement equivalence. This is also true wrt. other operators and their
>>>> default function. We have a number of lambda libraries in Boost, as well
>>>> as Boost.Proto and Boost.Spirit that wouldn't have existed if we
>>>> followed your logic.
>>>
>>> No, I addressed that. Even in lambda libraries, operator== should be
>>> used only for equivalence (as an indirection rather than directly), and
>>> as such it should still be commutative and agnostic of specific order.
>>> Assuming that, it shouldn't be broken by the C++20 changes.
>>
>> In template expressions, operators are generally not commutative because
>> the type of the result depends on types of the left and right arguments.
>
> Isn't the result of "==" always boolean?

The result can have any type. However, the rewritten candidates for
operator== are only generated when the result is bool, so expression
templates should be unaffected by this operator rewriting. I'm not sure
about other comparison operators, though.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk