C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::arithmetic (concept)

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Sat, 12 Apr 2025 18:12:35 +0100
On Sat, 12 Apr 2025, 18:08 Howard Hinnant via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> Ancedote:
>
> std::integral recently fell out of favor with me and I wrote my own
> concept that better suited my needs:
>
> https://github.com/HowardHinnant/bbi/blob/master/bbi.h#L176-L191
>
> StandardSignedInteger
> StandardUnsignedInteger
> StandardInteger
>
> The difference here is that my concepts exclue bool and the character
> types.


Much more useful. Treating bool as an integer is almost never what you
want.

But at least we didn't make it a standard unsigned integer type like C did!


This distinction was at best not clear in C++11, and not modeled by the
> type_traits introduced then. For my work today, it is important to not
> include bool and the character types as “integral types” as their semantics
> are not consistent with the representaiton of integral numbers.
>
> I mention this ancedote as a word of caution for building further concepts
> on top of type_traits. type_traits was a good model of the type system
> when they were introduced, but may not be today, 15 years later.
>
> Howard
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2025-04-12 17:12:53