Question

Giving this:

void foo(const matrix<double>& lol)
{
    matrix_row<matrix<double> > lolwut(lol, 5);
}

error:

no matching function for call to ‘boost::numeric::ublas::matrix_row<boost::numeric::ublas::matrix<double> >::matrix_row(const boost::numeric::ublas::matrix<double>&, size_t&)’

How to unconst the reference given in the function's parameter or which workaround to use? I'm not sure if simple assignment

matrix<double> tmp = lol;

will not have any overhead.

Était-ce utile?

La solution

Here is how you do this using BOOST_AUTO:

void foo(const matrix<double>& lol)
{
    matrix_row< const matrix<double> > lolwut(lol, 5);
}

The spaces are needed if you are compiling to C++ < 11 otherwise some buggy compilers will interpret it as a right bit-shift (>>) operator

Autres conseils

Try using BOOST_AUTO.

Code:

BOOST_AUTO(r, row(lol, 5));
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top