cisst-saw
|
A collection of useful information about the C++ basic types, represented in a generic programming way. More...
#include <cmnTypeTraits.h>
Public Types | |
typedef _elementType | Type |
typedef bool | BoolType |
typedef cmnVaArgPromotion < _elementType >::Type | VaArgPromotion |
Public Member Functions | |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasSign (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | HasInfinity (void) |
template<> | |
bool | IsFinite (const float &value) |
template<> | |
bool | IsFinite (const double &value) |
template<> | |
bool | IsFinite (const long long int &CMN_UNUSED(value)) |
template<> | |
bool | IsFinite (const int &CMN_UNUSED(value)) |
template<> | |
bool | IsFinite (const short &CMN_UNUSED(value)) |
template<> | |
bool | IsFinite (const char &CMN_UNUSED(value)) |
template<> | |
bool | IsFinite (const unsigned long long int &CMN_UNUSED(value)) |
template<> | |
bool | IsFinite (const unsigned int &CMN_UNUSED(value)) |
template<> | |
bool | IsFinite (const unsigned short &CMN_UNUSED(value)) |
template<> | |
bool | IsFinite (const unsigned char &CMN_UNUSED(value)) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | HasNaN (void) |
template<> | |
bool | IsNaN (const float &value) |
template<> | |
bool | IsNaN (const double &value) |
template<> | |
bool | IsNaN (const long long int &CMN_UNUSED(value)) |
template<> | |
bool | IsNaN (const int &CMN_UNUSED(value)) |
template<> | |
bool | IsNaN (const short &CMN_UNUSED(value)) |
template<> | |
bool | IsNaN (const char &CMN_UNUSED(value)) |
template<> | |
bool | IsNaN (const unsigned long long int &CMN_UNUSED(value)) |
template<> | |
bool | IsNaN (const unsigned int &CMN_UNUSED(value)) |
template<> | |
bool | IsNaN (const unsigned short &CMN_UNUSED(value)) |
template<> | |
bool | IsNaN (const unsigned char &CMN_UNUSED(value)) |
Static Public Member Functions | |
static Type | Tolerance (void) |
static void | SetTolerance (Type tolerance) |
static CISST_EXPORT std::string | TypeName (void) |
static Type | PlusInfinityOrMax (void) |
static Type | MinusInfinityOrMin (void) |
static CISST_EXPORT Type | MaxPositiveValue (void) |
static CISST_EXPORT Type | MinPositiveValue (void) |
static CISST_EXPORT Type | MaxNegativeValue (void) |
static CISST_EXPORT Type | MinNegativeValue (void) |
static CISST_EXPORT Type | PlusInfinity (void) |
static CISST_EXPORT Type | MinusInfinity (void) |
static CISST_EXPORT bool | HasSign (void) |
static bool | HasInfinity (void) |
static bool | IsFinite (const Type &value) |
static CISST_EXPORT Type | NaN (void) |
static CISST_EXPORT bool | IsNaN (const Type &value) |
static bool | HasNaN (void) |
Static Public Attributes | |
static CISST_EXPORT const Type | DefaultTolerance |
A collection of useful information about the C++ basic types, represented in a generic programming way.
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
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:
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 | The template parameter which defined the type. |
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.
typedef _elementType cmnTypeTraits< _elementType >::Type |
The type in question
typedef cmnVaArgPromotion<_elementType>::Type cmnTypeTraits< _elementType >::VaArgPromotion |
The promotion of the type when passed in a va_arg list
|
inlinestatic |
Check if this type has a meaningful positive infinity and negative infinity.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Check if this type has a meaningful Not A Number.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Return true if this type has signed, e.g., for signed int, double, etc. Return false if this type is unsigned.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Test if the value is finite.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Test if the value is nan.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
The greatest negative value possible for the type (minus one for integral types, a small negative fraction for floating point types).
|
static |
The greatest positive value possible for the type.
|
static |
The smallest negative value possible for the type, that is, the negative value of greatest magnitude.
|
static |
The smallest positive value possible for the type (one for integral types, a small positive fraction for floating point types).
|
static |
Negative infinity special value, defined for floating point types For templated code, one can use HasInfinity to check if this method is meaningful.
|
inlinestatic |
Return a negative number which is infinity, if available, or the smallest possible negative value otherwise. This function is useful for ``idempotent max'' operation.
|
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 |
Positive infinity special value, defined for floating point types. For templated code, one can use HasInfinity to check if this method is meaningful.
|
inlinestatic |
Return a positive number which is infinity, if available, or the greatest possible positive value otherwise. This function is useful for ``idempotent min'' operation.
|
inlinestatic |
Set the numerical tolerance for this type.
|
inlinestatic |
Return the numerical tolerance value for computation results.
|
static |
The name of the type.
|
static |
The tolerance for the specific type.