Date: Thu, 4 Sep 2025 14:59:48 +0200
On 04/09/2025 14:31, Yexuan Xiao via Std-Proposals wrote:
>
> A few years ago when I learned that _Bitint was included in C23, I also
> thought about this issue many times. My conclusion is that implementing
> it using a class template is really not a good idea, and using a
> built-in type would make things easier for its users. However, I believe
> that using a library to address the surprising results of integer
> promotions in bitwise operations is better than using _Bitint.
> Additionally, I’m not a fan of the underscore in the name bit_int.
>
The name _BitInt is from C, where there are no namespaces - so new
keywords generally have to be taken from a reserved identifier space and
thus are typically underscore and then a capital letter.
IMHO, C++ should support the keyword and name _BitInt for compatibility
with C here. It should /also/ support a C++ style std::bit_int<N> style
for people writing C++ code. The two names should refer to the same
type - perhaps simply by making _BitInt a pre-defined macro. Any C++
additions to _BitInt (such as, say, specialisations for hash or swap)
would be documented for the C++ style name.
>
> A few years ago when I learned that _Bitint was included in C23, I also
> thought about this issue many times. My conclusion is that implementing
> it using a class template is really not a good idea, and using a
> built-in type would make things easier for its users. However, I believe
> that using a library to address the surprising results of integer
> promotions in bitwise operations is better than using _Bitint.
> Additionally, I’m not a fan of the underscore in the name bit_int.
>
The name _BitInt is from C, where there are no namespaces - so new
keywords generally have to be taken from a reserved identifier space and
thus are typically underscore and then a capital letter.
IMHO, C++ should support the keyword and name _BitInt for compatibility
with C here. It should /also/ support a C++ style std::bit_int<N> style
for people writing C++ code. The two names should refer to the same
type - perhaps simply by making _BitInt a pre-defined macro. Any C++
additions to _BitInt (such as, say, specialisations for hash or swap)
would be documented for the C++ style name.
Received on 2025-09-04 12:59:51