1
是否增加或減少限制限定指針不保留別名假設?限制限定符和指針運算
// a and b point to disjoint arrays
void foo(size_t n, double * __restrict a, double * __restrict b) {
size_t i;
double x, y, z;
double * c = b; // copy
for(i=0; i<n; ++i) {
x = *(a++); // not aliased
y = *(b + i); // not aliased
z = c[i]; // not aliased
}
}
謝謝。
[mode pedantic]'restrict'在C99中拼寫時沒有下劃線,因爲它是一個語言關鍵字。儘管某些實現提供了替代,但在任何?C++標準中都沒有'restrict'這樣的東西。[/ mode] – 2011-05-22 09:56:57
__restrict限定符是一個並不少見的擴展,在幾個C和C++編譯器中都受到支持。 – 2011-05-22 10:09:02