Blaze  3.6
blaze::CrossTrait< T1, T2, typename > Struct Template Reference

Base template for the CrossTrait class. More...

#include <CrossTrait.h>

Detailed Description

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

Base template for the CrossTrait class.

General

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


Creating custom specializations

Per default, CrossTrait supports all vector types of the Blaze library (including views and adaptors). For all other data types it is possible to specialize the CrossTrait template. The following example shows the according specialization for the cross product between two static column vectors:

template< typename T1, typename T2 >
struct CrossTrait< StaticVector<T1,3UL,false>, StaticVector<T2,3UL,false> >
{
using Type = StaticVector< typename SubTrait< typename MultTrait<T1,T2>::Type
, typename MultTrait<T1,T2>::Type >::Type, 3UL, false >;
};


Examples

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

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