C++ Logo

std-proposals

Advanced search

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

From: Bjorn Reese <breese_at_[hidden]>
Date: Thu, 4 Sep 2025 15:02:04 +0200
On 9/3/25 09:03, David Brown via Std-Proposals wrote:

> While code like that /uses/ implicit bool-to-int conversions, having
> those conversions be implicit is not at all necessary. If the
> conversions were not implicit, you'd simply write :
>
> return int(x >= T(0) - int(x <= T(0));

Presumably you meant to explictly cast to T rather than int, otherwise
it would fail for SIMD types.

In the generic case there may be no implicit cast at all. The comparison
may return a mask type, and the operators have overloads to handle the
combination of T and its associated mask type.

Received on 2025-09-04 13:02:06