Can I `__restrict__ this` somehow?

前端 未结 2 742
野的像风
野的像风 2021-01-24 20:12

I\'ve been watching Mike Acton\'s talk on Data-oriented design in C++ in CppCon 2014, and he gives this example:

int Foo::Bar(int count)
{
    int value = 0;
            


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-24 20:44

    1. __restrict__ is not standardized in C++, so this question can only be answered on a particular platform. For GCC, you can apply __restrict__ to this in the same way as const:

      void T::fn () __restrict__
      
    2. There is no potential aliasing in your example. C++ specifies undefined behavior for data races.

    3. A new system for C++ restricted pointers is being developed. It will likely be standardized in C++17. Support for this is one of the stated design goals.

提交回复
热议问题