gpt4 book ai didi

c++ - 为什么 C++ 随机数生成不支持有符号/无符号 8 位整数类型?

转载 作者:行者123 更新时间:2023-12-01 13:09:09 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





Why Aren't `std::uniform_int_distribution<uint8_t>` and `std::uniform_int_distribution<int8_t>` Allowed?

(1 个回答)


去年关闭。




从 C++11 §26.5.1.1 关于随机数生成的要求:

Throughout this subclause 26.5, the effect of instantiating a template: [...] that has a template type parameter named IntType is undefined unless the corresponding template argument is cv-unqualified and is one of short, int, long, long long, unsigned short, unsigned int, unsigned long, or unsigned long long.



是什么原因8 位 在要求中,像这样的随机数生成不包括有符号/无符号类型?

最佳答案

这个问题被提出为 LWG Issue 2326 ,它被关闭为“不是缺陷”。

不是因为人们不赞成,而是因为它是一个新功能,而不是一个错误。委员会认为,写一篇论文讨论做出这种改变的利弊会更好地服务于这一点。

目前,还没有人写过这样的论文。

正如@NathanOliver 所指出的,这个问题是 asked before那里的链接表明这有点争议。

关于c++ - 为什么 C++ 随机数生成不支持有符号/无符号 8 位整数类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60385263/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com