blaze::DivTrait< T1, T2 > Struct Template Reference

Base template for the DivTrait class. More...

#include <DivTrait.h>

Detailed Description

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

Base template for the DivTrait class.

General

The DivTrait class template offers the possibility to select the resulting data type of a generic division operation between the two given types T1 and T2. SidTrait defines the nested type Type, which represents the resulting data type of the division. In case the two types T1 and T2 cannot be divided, the resulting data type Type is set to INVALID_TYPE. Note that const and volatile qualifiers and reference modifiers are generally ignored.

Per default, the DivTrait template provides specializations for the following built-in data types:

Additionally, the Blaze library provides appropriate specializations for the following user-defined arithmetic types:


Creating custom specializations

It is possible to specialize the DivTrait template for additional user-defined data types. The following example shows the according specialization for the division between a dynamic column vector and a scalar double precision value:

template< typename T1 >
struct DivTrait< DynamicVector<T1,columnVector>, double >
{
typedef DynamicVector< typename DivTrait<T1,double>::Type, columnVector > Type;
};


Examples

The following example demonstrates the use of the DivTrait 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 DivTrait<T1,T2>::Type // The resulting generic return type
div( T1 t1, T2 t2 ) //
{ // The function 'div' returns the
return t1 / t2; // quotient of the two given values
} //

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