#include <cmnTypeTraits.h>
Collaboration diagram for cmnTypeTraits< _elementType >:

When using generic programming, there is a lot of type information to consider. For example, numeric tolerance values, type promotions, the name of the type, numerical limits, and so on. The standard C++ headers contain this information, but it is not organized in an accessible manner for generic programming. The purpose of this class is to provide a common representation for type-dependent information.
For example, to check that the result of a computation is correct within the accepted numerical tolerance for the type of operands, write something like
_elementType myVariable; if (myVariable < cmnTypeTraits<_elementType>::Tolerance()) { doSomething(); };
The default tolerance for a float is set to 1.0e-5f and for a double it is set to 1.0e-9.
The macros va_list, va_arg, etc. can be used with an ellipsis "..." to declare a method or function with an undetermined number of arguments. To retrieve an argument from the stack, it is then required to provided the type of the data used, e.g. myVariable = va_arg(myArgs, double). To use va_arg in a templated class such as:
template <class _elementType> myClass { }
one could imagine a call like va_arg(myArgs, _elementType). Unfortunatly, some types are automatically promoted (see ANSI C 89). For example, to get a char, one has to use int and to get a float, use a double.
By default, the internal type VaArgPromotion is the same as the template parameter. The class is specialized for the types which require a promotion.
The class can then be used in the following way:
_elementType myVariable; myVariable = static_cast<_elementType>(va_arg(nextArg, typename cmnTypeTraits<_elementType>::VaArgPromotion));
| _elementType | The template parameter which defined the type. |
Definition at line 158 of file cmnTypeTraits.h.
| typedef _elementType cmnTypeTraits< _elementType >::Type |
The type in question
Definition at line 161 of file cmnTypeTraits.h.
| typedef bool cmnTypeTraits< _elementType >::BoolType |
Boolean type. This has been added to delay the instantiation of some templated code by gcc 4.0. This type is used to define vctDynamicConstVectorBase::BoolVectorValueType and vctDynamicConstMatrixBase::BoolMatrixValueType.
Definition at line 167 of file cmnTypeTraits.h.
| typedef cmnVaArgPromotion<_elementType>::Type cmnTypeTraits< _elementType >::VaArgPromotion |
The promotion of the type when passed in a va_arg list
Definition at line 170 of file cmnTypeTraits.h.
| static Type cmnTypeTraits< _elementType >::Tolerance | ( | void | ) | [inline, static] |
Return the numerical tolerance value for computation results.
Definition at line 173 of file cmnTypeTraits.h.
Referenced by vctDynamicConstMatrixBase< vctDynamicMatrixOwner< float >, float >::AlmostEqual(), vctDynamicConstNArrayBase< vctDynamicNArrayRefOwner< _elementType, _dimension >, _elementType, _dimension >::AlmostEqual(), vctDynamicConstVectorBase< vctDynamicVectorOwner< svlFilterSourceVideoCapture::_ImageFormat >, svlFilterSourceVideoCapture::_ImageFormat >::AlmostEqual(), vctQuaternionRotation3Base< vctFixedSizeVector< double, 4 > >::From(), vctDynamicConstVectorBase< vctDynamicVectorOwner< svlFilterSourceVideoCapture::_ImageFormat >, svlFilterSourceVideoCapture::_ImageFormat >::IsNormalized(), nmrPInverse(), nmrPInverseEconomy(), vctFixedSizeVectorBase< _size, 1, svlPoint2D, vctFixedSizeVectorTraits< svlPoint2D, _size, 1 >::array >::NormalizedSelf(), and vctDynamicVectorBase< vctDynamicVectorOwner< svlFilterSourceVideoCapture::_ImageFormat >, svlFilterSourceVideoCapture::_ImageFormat >::NormalizedSelf().
| static void cmnTypeTraits< _elementType >::SetTolerance | ( | Type | tolerance | ) | [inline, static] |
Set the numerical tolerance for this type.
Definition at line 178 of file cmnTypeTraits.h.
| static CISST_EXPORT std::string cmnTypeTraits< _elementType >::TypeName | ( | void | ) | [static] |
The name of the type.
| static Type cmnTypeTraits< _elementType >::PlusInfinityOrMax | ( | void | ) | [inline, static] |
Return a positive number which is infinity, if available, or the greatest possible positive value otherwise. This function is useful for ``idempotent min'' operation.
Definition at line 189 of file cmnTypeTraits.h.
References cmnTypeTraits< _elementType >::HasInfinity(), cmnTypeTraits< _elementType >::MaxPositiveValue(), and cmnTypeTraits< _elementType >::PlusInfinity().
| static Type cmnTypeTraits< _elementType >::MinusInfinityOrMin | ( | void | ) | [inline, static] |
Return a negative number which is infinity, if available, or the smallest possible negative value otherwise. This function is useful for ``idempotent max'' operation.
Definition at line 198 of file cmnTypeTraits.h.
References cmnTypeTraits< _elementType >::HasInfinity(), cmnTypeTraits< _elementType >::MinNegativeValue(), and cmnTypeTraits< _elementType >::MinusInfinity().
| static CISST_EXPORT Type cmnTypeTraits< _elementType >::MaxPositiveValue | ( | void | ) | [static] |
The greatest positive value possible for the type.
Referenced by vctBinaryOperations< _outputType, _input1Type, _input2Type >::Minimum::NeutralElement(), and cmnTypeTraits< _elementType >::PlusInfinityOrMax().
| static CISST_EXPORT Type cmnTypeTraits< _elementType >::MinPositiveValue | ( | void | ) | [static] |
The smallest positive value possible for the type (one for integral types, a small positive fraction for floating point types).
| static CISST_EXPORT Type cmnTypeTraits< _elementType >::MaxNegativeValue | ( | void | ) | [static] |
The greatest negative value possible for the type (minus one for integral types, a small negative fraction for floating point types).
| static CISST_EXPORT Type cmnTypeTraits< _elementType >::MinNegativeValue | ( | void | ) | [static] |
The smallest negative value possible for the type, that is, the negative value of greatest magnitude.
Referenced by cmnTypeTraits< _elementType >::MinusInfinityOrMin(), and vctBinaryOperations< _outputType, _input1Type, _input2Type >::Maximum::NeutralElement().
| static CISST_EXPORT Type cmnTypeTraits< _elementType >::PlusInfinity | ( | void | ) | [static] |
Positive infinity special value, defined for floating point types. For templated code, one can use HasInfinity to check if this method is meaningful.
Referenced by cmnTypeTraits< _elementType >::PlusInfinityOrMax().
| static CISST_EXPORT Type cmnTypeTraits< _elementType >::MinusInfinity | ( | void | ) | [static] |
Negative infinity special value, defined for floating point types For templated code, one can use HasInfinity to check if this method is meaningful.
Referenced by cmnTypeTraits< _elementType >::MinusInfinityOrMin().
| static CISST_EXPORT bool cmnTypeTraits< _elementType >::HasSign | ( | void | ) | [static] |
Return true if this type has signed, e.g., for signed int, double, etc. Return false if this type is unsigned.
| static bool cmnTypeTraits< _elementType >::HasInfinity | ( | void | ) | [inline, static] |
Check if this type has a meaningful positive infinity and negative infinity.
Referenced by cmnTypeTraits< _elementType >::MinusInfinityOrMin(), and cmnTypeTraits< _elementType >::PlusInfinityOrMax().
| static CISST_EXPORT Type cmnTypeTraits< _elementType >::NaN | ( | ) | [static] |
Special Not a Number value, defined for floating point types. For templated code, one can use HasNaN to check if this method is meaningful.
| static CISST_EXPORT bool cmnTypeTraits< _elementType >::IsNaN | ( | const Type & | value | ) | [static] |
Test if the value is nan.
| static bool cmnTypeTraits< _elementType >::HasNaN | ( | void | ) | [inline, static] |
Check if this type has a meaningful Not A Number.
CISST_EXPORT const Type cmnTypeTraits< _elementType >::DefaultTolerance [static] |
The tolerance for the specific type.
Definition at line 250 of file cmnTypeTraits.h.