Want to write a C++ wrapper for ublas' project function

313 Views Asked by At

Minimal code example:

#include <boost/numeric/ublas/matrix_proxy.hpp>

namespace bnu = boost::numeric::ublas;

template<class M, class IA>
bnu::matrix_indirect<M, IA> project (bnu::matrix_indirect<M, IA> &data,
    int row1, int row2, int col1, int col2) {
    return bnu::project(data,
        bnu::range(row1, row2), bnu::range(col1, col2));
}

#include <boost/numeric/ublas/matrix.hpp>

int main()
{
    bnu::matrix<int> m(4,4);
    project(m,0,1,0,1);
    return 0;
}

Compile like this:

g++ -Wall project.cpp -o project

It raises a compiler error:

> g++ -Wall project.cpp -o project
project.cpp: In function ‘int main()’:
project.cpp:16:19: error: no matching function for call to ‘project(boost::numeric::ublas::matrix<int>&, int, int, int, int)’
project.cpp:16:19: note: candidates are:
project.cpp:7:29: note: template<class M, class IA> boost::numeric::ublas::matrix_indirect<M, IA> project(boost::numeric::ublas::matrix_indirect<M, IA>&, int, int, int, int)
project.cpp:7:29: note:   template argument deduction/substitution failed:
project.cpp:16:19: note:   ‘boost::numeric::ublas::matrix<int>’ is not derived from ‘boost::numeric::ublas::matrix_indirect<M, IA>’
(more candidates to come, but these are not important here)

I guess my header for my version of project was not fitting (I copied the best suitable from /usr/include/boost/numeric/ublas/matrix_proxy.hpp). How to make it work?

0

There are 0 best solutions below