
Am Sonntag, den 03.12.2006, 13:15 +0100 schrieb Daniel Wesslén:
This should do it:
#include <math/matrix.tpp> using namespace math;
int main() {
const indexer<bits::index_swizzle<0,0,2,0> > xxzx; const indexer<bits::index_swizzle<3,2,1,0> > wzyx;
vector<4> v1, v2(1,2,3,4);
v1 = v2[xxzx]; // v1 = (1,1,3,1) // v1[xxzx] = v2; // error - v1[xxzx] is not a lvalue due to aliasing v1[wzyx] = v2; // v1 = (4,3,2,1)
}
I'm sorry if it was mentioned before, but g++ 3.4.6/ 4.1.1/ 4.2.0-alpha20061031 don't compile this <at math2-matrix-vector/src> g++-4.1.1 test.cc -I../include </at math2-matrix-vector/src> <error message> ../include/math/bits/basic_matrix.h: In member function 'Type math::bits::basic_matrix<Rows, Cols, Type>::element() const': ../include/math/bits/basic_matrix.h:27: error: there are no arguments to 'data' that depend on a template parameter, so a declaration of 'data' must be available ../include/math/bits/basic_matrix.h:27: error: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) ../include/math/bits/basic_matrix.h: In member function 'Type& math::bits::basic_matrix<Rows, Cols, Type>::element()': ../include/math/bits/basic_matrix.h:31: error: there are no arguments to 'data' that depend on a template parameter, so a declaration of 'data' must be available ../include/math/bits/tmatrix.h: In constructor 'math::tmatrix_dim<Rows, Cols, Base, Type>::tmatrix_dim(typename math::bits::if_bool_type<((Rows == 1) && (Cols == 1)), const Type&, math::tmatrix_dim<Rows, Cols, Base, Type>::dummy>::type)': ../include/math/bits/tmatrix.h:38: error: 'element' was not declared in this scope ../include/math/bits/tmatrix.h:38: error: expected primary-expression before ')' token ../include/math/bits/tmatrix.h: In member function 'math::tmatrix_dim<Rows, Cols, Base, Type>::operator typename math::bits::if_bool_type<((Rows == 1) && (Cols == 1)), Type&, math::tmatrix_dim<Rows, Cols, Base, Type>::dummy>::type()': ../include/math/bits/tmatrix.h:74: error: 'element' was not declared in this scope ../include/math/bits/tmatrix.h:74: error: expected primary-expression before ')' token ../include/math/constants.h: At global scope: ../include/math/constants.h:13: error: uninitialized const 'math::identity' ../include/math/constants.h:16: error: uninitialized const 'math::zero' </error message> Regards, Maik