gcc doesn't consider that

template<typename OtherDerived> TensorStridingOp& operator = (const OtherDerived& other)
provides a valid assignment operator for the striding operation, and therefore refuses to compile code like:
result.stride(foo) = source.stride(bar);

Added the explicit
   TensorStridingOp& operator = (const TensorStridingOp& other)

as a workaround to get the code to compile, and did the same in all the operations that can be used as lvalues.
This commit is contained in:
Benoit Steiner
2015-01-16 09:09:23 -08:00
parent 641e824c56
commit 14f537c296
8 changed files with 116 additions and 0 deletions

View File

@@ -89,6 +89,24 @@ static void test_striding_as_lvalue()
}
}
}
array<ptrdiff_t, 4> no_strides;
no_strides[0] = 1;
no_strides[1] = 1;
no_strides[2] = 1;
no_strides[3] = 1;
Tensor<float, 4, DataLayout> result2(3, 12, 10, 21);
result2.stride(strides) = tensor.stride(no_strides);
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j) {
for (int k = 0; k < 5; ++k) {
for (int l = 0; l < 7; ++l) {
VERIFY_IS_EQUAL(tensor(i,j,k,l), result2(2*i,4*j,2*k,3*l));
}
}
}
}
}