
Hi Kresimir, you wrote:
question is the following: Is it intentional, that it is not possible to compile:
#include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/io.hpp>
int main () { using namespace boost::numeric::ublas; matrix<double> m (4, 4); for (unsigned int i = 0; i < m.size1 (); ++ i) for (unsigned int j = 0; j < m.size2 (); ++ j) m(i, j) = 4*i+j;
std::cout << m << std::endl;
swap(row(m,0), row(m,2));
std::cout << m << std::endl; }
No. This one compiles with ICC 7.0 and fails with GCC 3.2.1.
It also fails with como. As it should.
Thanks for checking that!
This is the old problem of binding references to temporaries: parameters of `swap()' are *non-const* references, and they cannot be bound to temporaries returned by `row()'.
It seems that `project()' raises its ugly head again :o(
Not sure about that. Maybe swap()'s signatures are inadequate for the view classes. If I change matrix_row<>'s swap() member signatures from void swap (matrix_row &mr); friend void swap (matrix_row &mr1, matrix_row &mr2); to void swap (matrix_row mr); friend void swap (matrix_row mr1, matrix_row mr2); the following test program compiles on GCC 3.2.1 and Intel 7.0: ---------- #include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (4, 4); for (unsigned int i = 0; i < m.size1 (); ++ i) for (unsigned int j = 0; j < m.size2 (); ++ j) m(i, j) = 4*i+j; std::cout << m << std::endl; swap(row(m,0), row(m,2)); row(m,0).swap(row(m,2)); swap(m.row(0), m.row(2)); m.row(0).swap(m.row(2)); matrix_row<matrix<double> > r1(m, 0), r2(m, 2); swap(r1, r2); r1.swap(r2); std::cout << m << std::endl; } ---------- Interestingly enough, the same doesn't hold for 'const matrix_row &' instead ;-) I've already corrected swap() members for all view classes and intend to upload my current version after some regression testing. Thanks again, Joerg