限制在 header 和来源中的使用

Restrict usage in header and source

我们是否需要在方法的声明和定义中都使用 restrict 关键字,还是仅在 C++ 代码的声明文件中使用它就足够了?正确的使用方法是什么?

即使在声明中没有 restrict 用法,代码也能编译。

例如

Foo.h
class Foo
{
    public:
    void Bar(int* __restrict__ in, int* __restrict__ out);
}


Foo.cpp

void Foo::Bar(int* __restrict__ in, int* __restrict__ out)
{
}

接受@StoryTeller 的回答

    As with all outermost parameter qualifiers, __restrict__ is ignored in 
function definition matching. This means you only need to specify __restrict__ in 
a function definition, rather than in a function prototype as well." – StoryTeller 
May 8 at 10:25