#include <mlTypeTraits.h>
Public Types | |
| enum | { physicalDataType = -1, isBuiltInFloatType = false, isBuiltInIntegerType = false, isBuiltInSignedType = false, isStandardType = false, isAnyCarrierType = false, isCarrierOutType = false, isCarrierInType = false, isLDouble = false, is8BitInteger = false, is16BitInteger = false, is32BitInteger = false, is64BitInteger = false, is8_16_32BitInteger = false, isUnknown = true } |
Static Public Member Functions | |
| static MLint32 | isSignedType () |
| Returns if the type is signed, this is not a compile time constant for the carrier types and requires that the carrier type information is correctly set via MLTypeInfosPushAndSet*. | |
| static MLDataType | getDataType () |
| Returns the datatype of a type, this is identical to the physicalDataType for standard types but is the currently activated concrete datatype for carrier types. | |
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() { if (TypeTraits<T>::isBuiltInFloatType) { // we are working on a build in floating point type (double, float, ldouble) } else if (TypeTraits<T>::isBuiltInIntegerType) { // we are working on a build in integer type ([u]int(8|16|32|64)) } else { // we are a carrier type... } }
Definition at line 40 of file mlTypeTraits.h.
| anonymous enum |
| physicalDataType | Gives the physical data type for the given type, e.g., TypeTrait<MLuint8>::physicalDataType == MLuint8Type. |
| isBuiltInFloatType | Flag which is true if the type is a built-in floating point type (float, double, ldouble). |
| 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 carrier types!). |
| isStandardType | Flag which is true for all built-in types (and false for carrier types). |
| isAnyCarrierType | Flag which is true for all carrier types (in and out types). |
| isCarrierOutType | Flag which is true for out carrier types (CarrierN). |
| isCarrierInType | Flag which is true for in carrier types (CarrierNIn). |
| isLDouble | Flag which is true for the ldouble type. |
| 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 physical ML types and true for unknown types (e.g., TypeTraits<Module>::isUnknown == true). |
Definition at line 42 of file mlTypeTraits.h.
| static MLDataType ml::TypeTraits< T >::getDataType | ( | ) | [inline, static] |
Returns the datatype of a type, this is identical to the physicalDataType for standard types but is the currently activated concrete datatype for carrier types.
For carriertypes, it is not known at compile time and requires that the carrier type information is correctly set via MLTypeInfosPushAndSet*.
Definition at line 70 of file mlTypeTraits.h.
| static MLint32 ml::TypeTraits< T >::isSignedType | ( | ) | [inline, static] |
Returns if the type is signed, this is not a compile time constant for the carrier types and requires that the carrier type information is correctly set via MLTypeInfosPushAndSet*.
If you are only interested in standard types, you may use isBuiltInSignedType, which is always known at compile time.
Definition at line 64 of file mlTypeTraits.h.
1.5.8