__restrict in g++ and MSVC with Array Syntax

随声附和 提交于 2019-12-24 04:41:13

问题


I'm in the process of updating performance critical libraries to use restrict, as implemented in C++11 by g++ and MSVC with the keyword __restrict.

There are a lot of routines and functions that look something like:

void f(float a[],float b[]);

In the above example, f is a routine whose arguments should be restricted. Unfortunately, as far as I can tell, this is impossible while maintaining that syntax. Now, clearly this can be rewritten using pointers as:

void f(float*__restrict a,float*__restrict b);

What got lost here is the semantic fact that a and b are arrays (I prefer using pointer notation for single-value pointers and array notation for array pointers). Descriptive argument names (omitted above) help, but only so much.

I would like to confirm that declaring restricted variables using array syntax is impossible for these compilers at this time.

来源:https://stackoverflow.com/questions/25929162/restrict-in-g-and-msvc-with-array-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!