cusp::csr_matrix<int,float,cusp::device_memory> mtx = *(csr_matrix *)this;
This cast can never call a conversion function because the type of the operand this
of the cast expression is CuspMatrix*
. A conversion function will only be considered when the type of the operand is a class type:
cusp::csr_matrix<int,float,cusp::device_memory> mtx = (csr_matrix)*this;
In this scenario, csr_matrix is already a public base class of CuspMatrix
- so the conversion function CuspMatrix::operator csr_matrix()
, can never be called.
This upward-conversion does not require a cast - when this
is of type CuspMatrix*
and cusp::csr_matrix<int,float,cusp::device_memory>
supports assignment from cusp::csr_matrix<int,float,cusp::host_memory>
, you should be able to do this:
cusp::csr_matrix<int,float,cusp::device_memory> mtx = *this;
Without seeing the actual error messages and a compilable example, it's difficult to answer the second question.