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

@@ -161,6 +161,8 @@ static void test_slice_as_lvalue()
tensor3.setRandom();
Tensor<float, 3, DataLayout> tensor4(4,3,2);
tensor4.setRandom();
Tensor<float, 3, DataLayout> tensor5(10,13,12);
tensor5.setRandom();
Tensor<float, 3, DataLayout> result(4,5,7);
Eigen::DSizes<ptrdiff_t, 3> sizes12(2,2,7);
@@ -195,6 +197,17 @@ static void test_slice_as_lvalue()
}
}
}
Eigen::DSizes<ptrdiff_t, 3> sizes5(4,5,7);
Eigen::DSizes<ptrdiff_t, 3> fifth_slice(0,0,0);
result.slice(fifth_slice, sizes5) = tensor5.slice(fifth_slice, sizes5);
for (int i = 0; i < 4; ++i) {
for (int j = 2; j < 5; ++j) {
for (int k = 0; k < 7; ++k) {
VERIFY_IS_EQUAL(result(i,j,k), tensor5(i,j,k));
}
}
}
}
template<int DataLayout>