Hi everyone,

My compiler MSVS 2005 give an error when I try to compile a Matrix class with traits and policies for zero initialisation and return types.

Here is a snippet of my Traits.h :

Code:

namespace LinAlg
{
template<typename T1, typename T2>
struct ReturnType;
// partial specialisation for Complex - I
template<>
struct ReturnType<Complex, Complex>
{
typedef Complex Return;
};
// partial specialisation for Complex - II
template<>
struct ReturnType<Real, Complex>
{
typedef Complex Return;
};
// partial specialisation for Complex - III
template<>
struct ReturnType<Complex, Real>
{
typedef Complex Return;
};
// specialisation for Real: Real return type iff both arguments Real
template<>
struct ReturnType<Real, Real>
{
typedef Real Return;
};
}; // end namespace

and this is my (free) operator+ template:

Code:

// addition
template<typename T1, typename T2> Matrix<typename ReturnType<T1, T2> :: ResultT>
operator+( Matrix<T1> const& A1, Matrix<T2> const& A2)
{
Matrix<typename ReturnType<T1, T2> :: ResultT> result( A1);
return ( result += A2);
}

The error message is

with most important line:

[cc] testMatrix.cpp

[cc] D:\V5.1.0\visual.static.frame.HEAD\must\com.airbus .must.static.data.service\src\pluginlib\cxx\test\t estMatrix.cpp(55) : error C2893: Failed to specialize function template 'LinAlg :: Matrix<

ReturnType<T1,T2>::ResultT> LinAlg :: operator +(const LinAlg :: Matrix<T> &,const LinAlg :: Matrix<T2> &)'

[cc] With the following template arguments:

[cc] 'Real'

[cc] 'Complex'

Thanks a huge lot for your help!!!