Blaze  3.6
blaze::ElementsTrait< VT, N > Struct Template Reference

Base template for the ElementsTrait class. More...

#include <ElementsTrait.h>

Detailed Description

template<typename VT, size_t N>
struct blaze::ElementsTrait< VT, N >

Base template for the ElementsTrait class.

General

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

template< typename T1, bool TF, size_t N >
struct ElementsTrait< DynamicVector<T1,TF>, N >
{
using Type = DynamicVector<T1,TF>;
};


Examples

The following example demonstrates the use of the ElementsTrait template, where depending on the given vector type the according result type is selected:

// Definition of the result type of a dynamic column vector
using ResultType1 = typename blaze::ElementsTrait<VectorType1,0UL>::Type;
// Definition of the result type for two elements of a static row vector
using ResultType2 = typename blaze::ElementsTrait<VectorType2,2UL>::Type;

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