C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Should postfix increment and decrement operators be automatically obtainable from their prefix versions?

From: Jan Schultke <janschultke_at_[hidden]>
Date: Wed, 24 Jan 2024 16:35:27 +0100
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.

Received on 2024-01-24 15:35:40