Date: Wed, 24 Jan 2024 12:55:35 -0500
On Wed, Jan 24, 2024 at 11:13 AM Jonathan Wakely via Std-Proposals <
std-proposals_at_[hidden]> wrote:
>
>
> On Wed, 24 Jan 2024 at 15:37, Jan Schultke via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> This has already been proposed in P1046: Automatically Generate More
>> Operators, although with explicit = default. It didn't go further than
>> allowing defaulting ->.
>>
>> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1046r2.html
>>
>> I like the idea, but a strong reason against it is that you can also
>> default operator++(int) in terms of operator+, with no prefix
>> increment involved. You'd have to make a very strong case for
>> hardcoding a specific implementation in the core language instead of
>> letting the user decide.
>>
>
> Doing it that way is only valid for random access iterators (or more
> precisely, ones which provide operator+ which usually means random access)
> and is vanishingly rare in my experience. I would have no problem
> whatsoever saying that the default definition does the obvious thing, and
> if you want to define it differently you just have to write it by hand.
>
Also, the implementation that calls operator+ is extremely unlikely to ever
be preferable to the one that uses prefix operator++. You have to make a
copy in both cases.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
std-proposals_at_[hidden]> wrote:
>
>
> On Wed, 24 Jan 2024 at 15:37, Jan Schultke via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> This has already been proposed in P1046: Automatically Generate More
>> Operators, although with explicit = default. It didn't go further than
>> allowing defaulting ->.
>>
>> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1046r2.html
>>
>> I like the idea, but a strong reason against it is that you can also
>> default operator++(int) in terms of operator+, with no prefix
>> increment involved. You'd have to make a very strong case for
>> hardcoding a specific implementation in the core language instead of
>> letting the user decide.
>>
>
> Doing it that way is only valid for random access iterators (or more
> precisely, ones which provide operator+ which usually means random access)
> and is vanishingly rare in my experience. I would have no problem
> whatsoever saying that the default definition does the obvious thing, and
> if you want to define it differently you just have to write it by hand.
>
Also, the implementation that calls operator+ is extremely unlikely to ever
be preferable to the one that uses prefix operator++. You have to make a
copy in both cases.
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
-- *Brian Bi*
Received on 2024-01-24 17:55:50