C++ Logo

std-proposals

Advanced search

Re: [std-proposals] D3666R0 Bit-precise integers

From: David Brown <david.brown_at_[hidden]>
Date: Tue, 2 Sep 2025 23:21:30 +0200
On 02/09/2025 20:38, Sebastian Wittmeier via Std-Proposals wrote:
> Disallowing additions of (implicitly int-converted) bool values is a bad
> idea.
>
> A huge advantage of C++ is the long compatibility for low-level
> algorithms. They can just be inserted and compiled.
> bool a = true;
> bool b = true;
> bool c = false;
> if (a + b + c >= 2) ...; // test whether at least two booleans are true
>

I agree that suitability for low-level work is a huge advantage of C++.
But that does not mean it needs to have implicit conversions - explicit
conversions would do the job fine :

 if (int(a) + int(b) + int(c) >= 2) ....

It is very rare IME that you need to add bools - having an explicit cast
would not be a problem.

> We should create the std::strong_bool instead or use some bool profile.
>
>

Received on 2025-09-02 21:21:37