问题
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