blaze::MultTrait< T1, T2, typename > Struct Template Reference

Base template for the MultTrait class. More...

#include <MultTrait.h>

Detailed Description

template<typename T1, typename T2, typename>
struct blaze::MultTrait< T1, T2, typename >

Base template for the MultTrait class.

General

The MultTrait class template offers the possibility to select the resulting data type of a generic multiplication operation between the two given types T1 and T2. MultTrait defines the nested type Type, which represents the resulting data type of the multiplication. In case the two types T1 and T2 cannot be multiplied, a compilation error is created. Note that const and volatile qualifiers and reference modifiers are generally ignored.


Creating custom specializations

MultTrait is guaranteed to work for all built-in data types, complex numbers, all vector and matrix types of the Blaze library (including views and adaptors) and all data types that provide a multiplication operator (i.e. operator*). In order to add support for user-defined data types that either don't provide a multiplication operator or whose multiplication operator returns a proxy object instead of a concrete type (as it is common in expression template libraries) it is possible to specialize the MultTrait template. The following example shows the according specialization for the multiplication between two dynamic column vectors:

template< typename T1, typename T2 >
struct MultTrait< DynamicVector<T1,columnVector>, DynamicVector<T2,columnVector> >
{
using Type = DynamicVector< typename MultTrait<T1,T2>::Type, columnVector >;
};


Examples

The following example demonstrates the use of the MultTrait template, where depending on the two given data types the resulting data type is selected:

template< typename T1, typename T2 > // The two generic types
typename MultTrait<T1,T2>::Type // The resulting generic return type
mult( const T1& t1, const T2& t2 ) //
{ // The function 'mult' returns the
return t1 * t2; // product of the two given values
} //

The documentation for this struct was generated from the following file: