Allow multiplication like binary operators to be applied on type couples supported by scalar_product_traits

This commit is contained in:
Gael Guennebaud
2013-03-20 21:19:16 +01:00
parent f350f34560
commit c519be2bac
4 changed files with 26 additions and 13 deletions

View File

@@ -186,23 +186,35 @@ template<int Y, int InfX, int SupX>
class meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
/** \internal determines whether the product of two numeric types is allowed and what the return type is */
template<typename T, typename U> struct scalar_product_traits;
template<typename T, typename U> struct scalar_product_traits
{
enum { Defined = 0 };
};
template<typename T> struct scalar_product_traits<T,T>
{
//enum { Cost = NumTraits<T>::MulCost };
enum {
// Cost = NumTraits<T>::MulCost,
Defined = 1
};
typedef T ReturnType;
};
template<typename T> struct scalar_product_traits<T,std::complex<T> >
{
//enum { Cost = 2*NumTraits<T>::MulCost };
enum {
// Cost = 2*NumTraits<T>::MulCost,
Defined = 1
};
typedef std::complex<T> ReturnType;
};
template<typename T> struct scalar_product_traits<std::complex<T>, T>
{
//enum { Cost = 2*NumTraits<T>::MulCost };
enum {
// Cost = 2*NumTraits<T>::MulCost,
Defined = 1
};
typedef std::complex<T> ReturnType;
};