C ++标准中带有`restrict`关键字/属性的情况

Ant*_*hov 7 c++ standards restrict-qualifier c++20

In short, restrict is supposed to tell the compiler that the pointers cannot point into the same memory location. Which is very useful for, say, function arguments and further compiler optimization. In scientific computing, restrict is very widely used.

Currently, restrict keyword is only a part of C99, but not a part of C++. We know that a lot of C++ compilers support __restrict__ as an extension. This question also talks in detail about what restrict and __restrict__ do.

Now, the discussion in the aforementioned question happened a long time ago and does not talk about C++17, C++20, nor plans for future standards. I found n3988 proposal that discusses restrict-like aliases in C++, complexities with richer syntaxis in C++, and potential remedies.

According to the IBM blog (2014), n3988 was encouraged for future work.

This question talks about the history of restrict and C++ without anything conclusive regarding the actual implementation and mentions the papers I already listed or the one mentioned in the comments (p1296).

I was not able to find anything beyond that on the plans of supporting restrict in the upcoming C++ (as far as I know, it's not a part of C++17). It seems like a very useful functionality, so I wonder

  • if I missed something in terms of proposals/discussion?
  • is there other information on the restrict usage in C++?
  • are there alternative ways to make the compiler optimizations (allowed by __restrict__) possible by using only "standard" functionality?

Dav*_*ing 6

restrict即使在C ++ 20中,也没有C一样的东西。已经提到论文在2018年11月的初步演示中受到了好评,这也许是因为它避免了使用限定词的关键困难-即使是C语言,也没有人知道它如何与其余类型系统交互。部分原因是因为添加restrict不会更改任何一个指针的含义,而是会根据稍后对它们进行的算术运算来影响其与其他一组指针(其成员资格没有指定)的关系。另一部分是因为C ++允许使用类型进行如此多的操作:这std::vector<T *restrict>意味着什么,索引a的类型是std::vector<T> &restrict什么?

尚不清楚这种基于合同的方法将提供什么实际的优化机会。总的来说,关于合同和优化还有许多悬而未决的问题。