标题说明了一切.我很好奇为什么strict关键字不属于C ++?我对C ++不太了解,我仍然无法在网上找到任何可以阻止这一点的原因.没有人知道如果C ++标准使用与C相似的方式使用此关键字,会发生什么可怕的事情?就是根本不需要吗?
The title says it all. I am curious why is the restrict keyword not part of C++ ? I don't know much about C++, and I'm still not able to find anything online that would give a reason blocking this. Does anyone know what terrible things would happen, if a C++ standard would use this keyword similarly to the way C does? Is it just not needed at all?
更多说明:它与使用无关,也许我一生都不会从此关键字中受益.这个问题只是出于好奇,因为约束是C99以来C的一部分,也就是15年.
More explanation: It is not about using it, perhaps I will not have any benefit from this keyword in my whole life. This question is only about curiosity, since restrict is part of C since C99, that is 15 years.
也请阅读以下内容:我对技术原因感兴趣,而不是诸如他们只是不喜欢,不够酷"之类的意见
Read this as well: I'm interested in technical reasons, not opinions like "They just didn't like, it is not cool enough"
推荐答案在C ++中定义限制"存在多个问题,其中一些问题在WG论文N3635中列出:open-std/jtc1/sc22/wg21/docs/papers/2013/n3635.pdf">www.open-std/jtc1/sc22/wg21/docs/papers/2013/n3635.pdf面向C ++的类似限制的语义"
There are several issues in defining "restrict" in C++, some of them are listed in WG paper N3635: www.open-std/jtc1/sc22/wg21/docs/papers/2013/n3635.pdf "Towards restrict-like semantics for C++"
C ++中的限制可能会出现以下问题:
Some possible issues with restrict in C++ are:
- 使用此指针"限制Class成员和间接访问
- 将限制限定符传递到函数,函子,lambda和模板中
- 在函数内部转义限制指针值
- 重叠数组成员,步幅很大
文档还列出了一些对C ++的限制"支持有限的C ++编译器.
Document also list several C++ compilers with limited "restrict" support for C++.
N3635中也有一个有趣的历史记录,关于不包含对C ++的限制:
There is also interesting history note in N3635 about non-inclusion of restrict to C++:
在Mont Tremblant会议上审查C ++中C99的功能时,考虑了限制,但正在等待纸质提案,尽管没有人提出....
At the time of reviewing C99 feature inclusion in C++ during the Mont Tremblant meeting, restrict was considered but was waiting a paper proposal although none came forward....
Restrict是C99的一项功能,它从未设计用于类抽象,它可能与C ++中不常见的指针有关....它是专为C的细粒度别名而设计的,但不适用于C ++中基于类型的别名的
Restrict is a C99 feature and was never designed to work in class abstractions and it may have to do with that pointers are not common in C++. ... it was designed for fine-grain aliasing for C, but not well-designed for type-based aliasing in C++
更多推荐
为什么strict关键字不属于C ++?
发布评论