ML 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... | |
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):
Definition at line 46 of file mlTypeTraits.h.
typedef void ml::TypeTraits< T >::ComponentType |
Definition at line 48 of file mlTypeTraits.h.
typedef void ml::TypeTraits< T >::IntermediateType |
Definition at line 49 of file mlTypeTraits.h.
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 |
|
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 51 of file mlTypeTraits.h.
|
inlinestatic |
Return the data type.
Definition at line 71 of file mlTypeTraits.h.
|
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 69 of file mlTypeTraits.h.