MeVisLab Toolbox Reference
ml::TypeTraits< T > Struct Template Reference

TypeTraits for scalar ML Datatypes. More...

#include <mlTypeTraits.h>

Public Types

enum  {
  dataType = ML_INVALID_DATA_TYPE , isBuiltInFloatType = false , isBuiltInIntegerType = false , isBuiltInSignedType = false ,
  isScalarType = false , isStandardType = false , is8BitInteger = false , is16BitInteger = false ,
  is32BitInteger = false , is64BitInteger = false , is8_16_32BitInteger = false , isUnknown = true
}
 
typedef void ComponentType
 
typedef void IntermediateType
 

Static Public Member Functions

static bool matches (MLDataType)
 Return whether the template argument matches the given data type id. More...
 
static MLDataType getDataType ()
 Return the data type. More...
 

Detailed Description

template<typename T>
struct ml::TypeTraits< T >

TypeTraits for scalar ML Datatypes.

All traits are calculated at compile-time, so that they can be used for template meta programming.

A type trait can be used to take compile-time decisions instead of runtime decisions in your code. The traits are fully known at compile-time, so you can even use them in case statements of a switch.

The typical usage will be in templated code, e.g., a templated method (assuming the we are in the ml namespace):

template <typename T> void someTemplatedMethod() {
// we are working on a build in floating point type (double, float)
// we are working on a build in integer type ([u]int(8|16|32|64))
} else {
// we are an extended type...
}
}
@ isBuiltInFloatType
Flag which is true if the type is a built-in floating point type (float, double).
Definition: mlTypeTraits.h:57
@ isBuiltInIntegerType
Flag which is true if the type is a built-in integer type (ML[u]int[8|16|32|64).
Definition: mlTypeTraits.h:58

Definition at line 50 of file mlTypeTraits.h.

Member Typedef Documentation

◆ ComponentType

template<typename T >
typedef void ml::TypeTraits< T >::ComponentType

Definition at line 52 of file mlTypeTraits.h.

◆ IntermediateType

template<typename T >
typedef void ml::TypeTraits< T >::IntermediateType

Definition at line 53 of file mlTypeTraits.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename T >
anonymous enum
Enumerator
dataType 

Gives the data type ID for the given type, e.g., TypeTrait<MLuint8>::dataType == MLuint8Type, or ML_INVALID_DATA_TYPE if not defined.

isBuiltInFloatType 

Flag which is true if the type is a built-in floating point type (float, double).

isBuiltInIntegerType 

Flag which is true if the type is a built-in integer type (ML[u]int[8|16|32|64).

isBuiltInSignedType 

Flag which is true if the type supports negative values (only for built-in types, use isSignedType() method for extended types!).

isScalarType 

Flag which is true for all built-in scalar types (and false for extended types).

isStandardType 
Deprecated:
use isScalarType instead
is8BitInteger 

Flag which is true for ML[u]int8 types.

is16BitInteger 

Flag which is true for ML[u]int16 types.

is32BitInteger 

Flag which is true for ML[u]int32 types.

is64BitInteger 

Flag which is true for ML[u]int64 types.

is8_16_32BitInteger 

Flag which is true for ML[u]int(8|16|32) types.

isUnknown 

Flag which is false for all known ML types and true for unknown types (e.g., TypeTraits<Module>::isUnknown == true).

Definition at line 55 of file mlTypeTraits.h.

Member Function Documentation

◆ getDataType()

template<typename T >
static MLDataType ml::TypeTraits< T >::getDataType ( )
inlinestatic

Return the data type.

Definition at line 75 of file mlTypeTraits.h.

◆ matches()

template<typename T >
static bool ml::TypeTraits< T >::matches ( MLDataType  )
inlinestatic

Return whether the template argument matches the given data type id.

Since by default types are not registered, we return true in this case. If you need a more strict test, compare directly with the dataType value.

Definition at line 73 of file mlTypeTraits.h.


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