boost, matrix_proxy, const matrix

boost, matrix_proxy, const matrix

本文关键字:matrix const proxy boost      更新时间:2023-10-16

给出这个:

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

错误:

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&)’

如何unconst函数参数中给出的引用,或者使用哪种解决方法?我不确定是否简单的任务

matrix<double> tmp = lol;

不会有任何开销。

以下是使用BOOST_AUTO:的方法

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

如果要编译到C++<11否则,一些有缺陷的编译器会将其解释为右移位(>>)运算符

尝试使用BOOST_AUTO

代码:

BOOST_AUTO(r, row(lol, 5));