-
Task
-
Resolution: Unresolved
-
P2: Important
-
None
-
None
-
None
-
Foundation PM Prioritized
We have q26::saturate_cast, which saturates, but we might also benefit from a checked narrowing conversion, that fails on out-of-range value instead of saturating, e.g. uint -> ushort, or, in the presence of Clang 21's -Wcharacter-conversion, char32_t -> char16_t. Currently, we either rely (in implementation) on old C semantics (where these are implicit and warning-free) or do them with an explicit cast (in headers, where -Wshorten-64-to-32 and -Wnarrowing are in effect for headerscheck).
This came up in several code changes recently, though I can't recall which ones, exactly, but I'm confident that we'll find lots of users for this function once it lands.