Date: Wed, 2 Jul 2025 09:31:18 +0200
Could it be that with contracts and their automated checks and enforcements, programmers will be more mindful about the range of the used types?
-----Ursprüngliche Nachricht-----
Von:Yexuan Xiao via Std-Proposals <std-proposals_at_[hidden]>
Gesendet:Mi 02.07.2025 09:26
Betreff:Re: [std-proposals] Shorter fixed-width integer types
An:Jan Schultke <janschultke_at_[hidden]>;
CC:Yexuan Xiao <bizwen_at_[hidden]>; C++ Proposals <std-proposals_at_[hidden]>;
The growing demand for handling massive data over the past decade has made more people aware of the limitations of int. For example, C# 9.0 added the keywords nint and nuint as aliases for IntPtr and UIntPtr. A friend of mine working on C# at Microsoft complained this year that C#’s Span not using IntPtr was a flaw. Perhaps more people will recognize the benefits of semantic type aliases in the future (though JavaScript opted to solve the problem with BigInt and IntArray since it previously had no integer type at all and couldn’t define aliases).
When not used for serialization, int is no worse than u16, but also no better. Defining a set of fixed-width integer aliases implemented with _BitInt might be useful—though I don’t have enough experience with _BitInt to be sure. I’m somewhat concerned about its interoperability with templates and existing standard library facilities. Moreover, promoting _BitInt without causing confusion might be just as challenging as promoting semantic type aliases.
--------------------------------
Received on 2025-07-02 07:40:18