C++ Logo

std-proposals

Advanced search

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

From: (wrong string) Åberg <haberg_1_at_[hidden]>
Date: Tue, 2 Sep 2025 21:30:01 +0200
> On 2 Sep 2025, at 20:38, Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]> 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
>
> We should create the std::strong_bool instead or use some bool profile.

The problem may not be with this conversion but the implicit conversion from int to bool. Specifically, for use in conditionals and switch statements, one may have to use conversions to int and bool, but the int value may be further converted to a bool, which can be wrong. I gave an example in another post.

Received on 2025-09-02 19:30:17