T
Tim Wesson
Does anyone know if it is possible to choose between the below
templates (or similar ones) according to the promotion rules for
types T and U?
Thanks,
Tim Wesson.
[...]
template<typename T, typename U>
inline matrix<T> operator+(const matrix<T>& m, const matrix<U>& n)
{ return matrix<T> (m) += n; }
template<typename T, typename U>
inline matrix<U> operator+(const matrix<T>& m, const matrix<U>& n)
{ return matrix<U> (m) += n; }
int main (void)
{
matrix<double> matd1, matd2;
matrix<float> matf1, matf2;
cout << matd1 * matf1 << '\n'; // should print matrix<double> ...
cout << matf2 * matd2 << '\n'; // should print matrix<double> ...
}
templates (or similar ones) according to the promotion rules for
types T and U?
Thanks,
Tim Wesson.
[...]
template<typename T, typename U>
inline matrix<T> operator+(const matrix<T>& m, const matrix<U>& n)
{ return matrix<T> (m) += n; }
template<typename T, typename U>
inline matrix<U> operator+(const matrix<T>& m, const matrix<U>& n)
{ return matrix<U> (m) += n; }
int main (void)
{
matrix<double> matd1, matd2;
matrix<float> matf1, matf2;
cout << matd1 * matf1 << '\n'; // should print matrix<double> ...
cout << matf2 * matd2 << '\n'; // should print matrix<double> ...
}