Blaze  3.6
blaze::DeclZeroTrait< T > Struct Template Reference

Base template for the DeclZeroTrait class. More...

#include <DeclZeroTrait.h>

Detailed Description

template<typename T>
struct blaze::DeclZeroTrait< T >

Base template for the DeclZeroTrait class.

General

The DeclZeroTrait class template offers the possibility to select the resulting data type of a generic declzero() operation on the given type T. DeclZeroTrait defines the nested type Type, which represents the resulting data type of the declzero() operation. In case the given data type is not a dense or sparse vector or matrix type, 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, DeclZeroTrait supports all vector and matrix types of the Blaze library (including views and adaptors). For all other data types it is possible to specialize the DeclZeroTrait template. The following example shows the according specialization for the SymmetricMatrix class template:

template< typename MT, bool SO, bool DF, bool NF >
struct DeclZeroTrait< SymmetricMatrix<MT,SO,DF,NF> >
{
using Type = ZeroMatrix< ElementType_t<MT>, SO >;
};


Examples

The following example demonstrates the use of the DeclZeroTrait template, where depending on the given vector or matrix type the resulting type is selected:

// Definition of the resulting type of a row-major dynamic matrix
using VectorType = DynamicVector<int,rowVector>;
using DeclZeroType1 = typename DeclZeroTrait<VectorType>::Type;
// Definition of the resulting type of a symmetric column-major static matrix
using MatrixType = SymmetricMatrix< StaticMatrix<int,3UL,3UL,columnMajor> >;
using DeclZeroType2 = typename DeclZeroTrait<MatrixType>::Type;

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