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 , 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) |
Returns whether the template argument matches the given data type id. More... | |
static MLDataType | getDataType () |
Returns 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 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):
Definition at line 51 of file mlTypeTraits.h.
typedef void ml::TypeTraits< T >::ComponentType |
Definition at line 53 of file mlTypeTraits.h.
typedef void ml::TypeTraits< T >::IntermediateType |
Definition at line 54 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 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.
|
inlinestatic |
Returns the data type.
Definition at line 75 of file mlTypeTraits.h.
|
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.