Date: Sun, 18 May 2025 12:35:58 +0200
> Hi Jan,
> why should const int not be included?
> In the example, they could be added.
Because one would assume that an integer allows for += and -= and
whatnot, but a const integer is missing these operations. The only way
to produce [T = const int] into functions taking T is by explicitly
providing const T as a template argument anyway, so you have to do
something pretty insane to need this behavior.
Also, the decision not to accept const int has been made in LEWG a
long time ago. Saturating arithmetic functions and any other place
using "signed or unsigned integer" as a constraint won't accept
cv-qualified types. std::integer is a formalization of this
design/wording idiom.
> why should const int not be included?
> In the example, they could be added.
Because one would assume that an integer allows for += and -= and
whatnot, but a const integer is missing these operations. The only way
to produce [T = const int] into functions taking T is by explicitly
providing const T as a template argument anyway, so you have to do
something pretty insane to need this behavior.
Also, the decision not to accept const int has been made in LEWG a
long time ago. Saturating arithmetic functions and any other place
using "signed or unsigned integer" as a constraint won't accept
cv-qualified types. std::integer is a formalization of this
design/wording idiom.
Received on 2025-05-18 10:36:15