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

#include <mlTypeTraits.h>

Public Types

enum  {
  dataType = ML_INVALID_DATA_TYPE , isBuiltInFloatType = false , isBuiltInIntegerType = false , isBuiltInSignedType = false ,
  isScalarType = 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)
static MLDataType getDataType ()
 Returns the data type.

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 make 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 built-in floating point type (double, float)
// we are working on a built-in integer type ([u]int(8|16|32|64))
} else {
// we are an extended type...
}
}
@ isBuiltInFloatType
Flag that is true if the type is a built-in floating point type (float, double).
@ isBuiltInIntegerType
Flag that is true if the type is a built-in integer type (ML[u]int[8|16|32|64).

Definition at line 51 of file mlTypeTraits.h.

Member Typedef Documentation

◆ ComponentType

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

Definition at line 53 of file mlTypeTraits.h.

◆ IntermediateType

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

Definition at line 54 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 that is true if the type is a built-in floating point type (float, double).

isBuiltInIntegerType 

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

isBuiltInSignedType 

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

isScalarType 

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

is8BitInteger 

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

is16BitInteger 

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

is32BitInteger 

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

is64BitInteger 

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

is8_16_32BitInteger 

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

isUnknown 

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

Definition at line 56 of file mlTypeTraits.h.

Member Function Documentation

◆ getDataType()

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

Returns the data type.

Definition at line 75 of file mlTypeTraits.h.

References dataType.

◆ matches()

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

Returns 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.

Referenced by ml::TSubImage< DATATYPE >::TSubImage(), ml::TSubImage< DATATYPE >::TSubImage(), ml::tsubimage_cast(), ml::tsubimage_cast(), ml::tsubimage_cast(), and ml::tsubimage_cast().


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