cisst-saw
Loading...
Searching...
No Matches
cmnTypeTraits< _elementType > Class Template Reference

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

bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasSign (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool HasInfinity (void)
bool IsFinite (const float &value)
bool IsFinite (const double &value)
bool IsFinite (const long long int &CMN_UNUSED(value))
bool IsFinite (const long int &CMN_UNUSED(value))
bool IsFinite (const int &CMN_UNUSED(value))
bool IsFinite (const short &CMN_UNUSED(value))
bool IsFinite (const char &CMN_UNUSED(value))
bool IsFinite (const unsigned long long int &CMN_UNUSED(value))
bool IsFinite (const unsigned long int &CMN_UNUSED(value))
bool IsFinite (const unsigned int &CMN_UNUSED(value))
bool IsFinite (const unsigned short &CMN_UNUSED(value))
bool IsFinite (const unsigned char &CMN_UNUSED(value))
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool HasNaN (void)
bool IsNaN (const float &value)
bool IsNaN (const double &value)
bool IsNaN (const long long int &CMN_UNUSED(value))
bool IsNaN (const long int &CMN_UNUSED(value))
bool IsNaN (const int &CMN_UNUSED(value))
bool IsNaN (const short &CMN_UNUSED(value))
bool IsNaN (const char &CMN_UNUSED(value))
bool IsNaN (const unsigned long long int &CMN_UNUSED(value))
bool IsNaN (const unsigned long int &CMN_UNUSED(value))
bool IsNaN (const unsigned int &CMN_UNUSED(value))
bool IsNaN (const unsigned short &CMN_UNUSED(value))
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 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

Detailed Description

template<class _elementType>
class cmnTypeTraits< _elementType >

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

_elementType myVariable;
doSomething();
};
static Type Tolerance(void)
Definition cmnTypeTraits.h:170

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));
cmnVaArgPromotion< _elementType >::Type VaArgPromotion
Definition cmnTypeTraits.h:167
Parameters
_elementTypeThe template parameter which defined the type.

Member Typedef Documentation

◆ BoolType

template<class _elementType>
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.

◆ Type

template<class _elementType>
typedef _elementType cmnTypeTraits< _elementType >::Type

The type in question

◆ VaArgPromotion

template<class _elementType>
typedef cmnVaArgPromotion<_elementType>::Type cmnTypeTraits< _elementType >::VaArgPromotion

The promotion of the type when passed in a va_arg list

Member Function Documentation

◆ HasInfinity() [1/13]

bool cmnTypeTraits< unsignedchar >::HasInfinity ( void )
inline

◆ HasInfinity() [2/13]

bool cmnTypeTraits< unsignedshort >::HasInfinity ( void )
inline

◆ HasInfinity() [3/13]

bool cmnTypeTraits< unsignedint >::HasInfinity ( void )
inline

◆ HasInfinity() [4/13]

bool cmnTypeTraits< unsignedlongint >::HasInfinity ( void )
inline

◆ HasInfinity() [5/13]

bool cmnTypeTraits< unsignedlonglongint >::HasInfinity ( void )
inline

◆ HasInfinity() [6/13]

bool cmnTypeTraits< char >::HasInfinity ( void )
inline

◆ HasInfinity() [7/13]

bool cmnTypeTraits< short >::HasInfinity ( void )
inline

◆ HasInfinity() [8/13]

bool cmnTypeTraits< int >::HasInfinity ( void )
inline

◆ HasInfinity() [9/13]

bool cmnTypeTraits< longint >::HasInfinity ( void )
inline

◆ HasInfinity() [10/13]

bool cmnTypeTraits< longlongint >::HasInfinity ( void )
inline

◆ HasInfinity() [11/13]

bool cmnTypeTraits< double >::HasInfinity ( void )
inline

◆ HasInfinity() [12/13]

bool cmnTypeTraits< float >::HasInfinity ( void )
inline

◆ HasInfinity() [13/13]

template<class _elementType>
bool cmnTypeTraits< _elementType >::HasInfinity ( void )
inlinestatic

Check if this type has a meaningful positive infinity and negative infinity.

◆ HasNaN() [1/13]

bool cmnTypeTraits< unsignedchar >::HasNaN ( void )
inline

◆ HasNaN() [2/13]

bool cmnTypeTraits< unsignedshort >::HasNaN ( void )
inline

◆ HasNaN() [3/13]

bool cmnTypeTraits< unsignedint >::HasNaN ( void )
inline

◆ HasNaN() [4/13]

bool cmnTypeTraits< unsignedlongint >::HasNaN ( void )
inline

◆ HasNaN() [5/13]

bool cmnTypeTraits< unsignedlonglongint >::HasNaN ( void )
inline

◆ HasNaN() [6/13]

bool cmnTypeTraits< char >::HasNaN ( void )
inline

◆ HasNaN() [7/13]

bool cmnTypeTraits< short >::HasNaN ( void )
inline

◆ HasNaN() [8/13]

bool cmnTypeTraits< int >::HasNaN ( void )
inline

◆ HasNaN() [9/13]

bool cmnTypeTraits< longint >::HasNaN ( void )
inline

◆ HasNaN() [10/13]

bool cmnTypeTraits< longlongint >::HasNaN ( void )
inline

◆ HasNaN() [11/13]

bool cmnTypeTraits< double >::HasNaN ( void )
inline

◆ HasNaN() [12/13]

bool cmnTypeTraits< float >::HasNaN ( void )
inline

◆ HasNaN() [13/13]

template<class _elementType>
bool cmnTypeTraits< _elementType >::HasNaN ( void )
inlinestatic

Check if this type has a meaningful Not A Number.

◆ HasSign() [1/13]

bool cmnTypeTraits< unsignedchar >::HasSign ( void )
inline

◆ HasSign() [2/13]

bool cmnTypeTraits< unsignedshort >::HasSign ( void )
inline

◆ HasSign() [3/13]

bool cmnTypeTraits< unsignedint >::HasSign ( void )
inline

◆ HasSign() [4/13]

bool cmnTypeTraits< unsignedlongint >::HasSign ( void )
inline

◆ HasSign() [5/13]

bool cmnTypeTraits< unsignedlonglongint >::HasSign ( void )
inline

◆ HasSign() [6/13]

bool cmnTypeTraits< char >::HasSign ( void )
inline

◆ HasSign() [7/13]

bool cmnTypeTraits< short >::HasSign ( void )
inline

◆ HasSign() [8/13]

bool cmnTypeTraits< int >::HasSign ( void )
inline

◆ HasSign() [9/13]

bool cmnTypeTraits< longint >::HasSign ( void )
inline

◆ HasSign() [10/13]

bool cmnTypeTraits< longlongint >::HasSign ( void )
inline

◆ HasSign() [11/13]

bool cmnTypeTraits< double >::HasSign ( void )
inline

◆ HasSign() [12/13]

bool cmnTypeTraits< float >::HasSign ( void )
inline

◆ HasSign() [13/13]

template<class _elementType>
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.

◆ IsFinite() [1/13]

bool cmnTypeTraits< char >::IsFinite ( const char & CMN_UNUSEDvalue)
inline

◆ IsFinite() [2/13]

bool cmnTypeTraits< double >::IsFinite ( const double & value)
inline

◆ IsFinite() [3/13]

bool cmnTypeTraits< float >::IsFinite ( const float & value)
inline

◆ IsFinite() [4/13]

bool cmnTypeTraits< int >::IsFinite ( const int & CMN_UNUSEDvalue)
inline

◆ IsFinite() [5/13]

bool cmnTypeTraits< longint >::IsFinite ( const long int & CMN_UNUSEDvalue)
inline

◆ IsFinite() [6/13]

bool cmnTypeTraits< longlongint >::IsFinite ( const long long int & CMN_UNUSEDvalue)
inline

◆ IsFinite() [7/13]

bool cmnTypeTraits< short >::IsFinite ( const short & CMN_UNUSEDvalue)
inline

◆ IsFinite() [8/13]

template<class _elementType>
bool cmnTypeTraits< _elementType >::IsFinite ( const Type & value)
static

Test if the value is finite.

◆ IsFinite() [9/13]

bool cmnTypeTraits< unsignedchar >::IsFinite ( const unsigned char & CMN_UNUSEDvalue)
inline

◆ IsFinite() [10/13]

bool cmnTypeTraits< unsignedint >::IsFinite ( const unsigned int & CMN_UNUSEDvalue)
inline

◆ IsFinite() [11/13]

bool cmnTypeTraits< unsignedlongint >::IsFinite ( const unsigned long int & CMN_UNUSEDvalue)
inline

◆ IsFinite() [12/13]

bool cmnTypeTraits< unsignedlonglongint >::IsFinite ( const unsigned long long int & CMN_UNUSEDvalue)
inline

◆ IsFinite() [13/13]

bool cmnTypeTraits< unsignedshort >::IsFinite ( const unsigned short & CMN_UNUSEDvalue)
inline

◆ IsNaN() [1/13]

bool cmnTypeTraits< char >::IsNaN ( const char & CMN_UNUSEDvalue)
inline

◆ IsNaN() [2/13]

bool cmnTypeTraits< double >::IsNaN ( const double & value)
inline

◆ IsNaN() [3/13]

bool cmnTypeTraits< float >::IsNaN ( const float & value)
inline

◆ IsNaN() [4/13]

bool cmnTypeTraits< int >::IsNaN ( const int & CMN_UNUSEDvalue)
inline

◆ IsNaN() [5/13]

bool cmnTypeTraits< longint >::IsNaN ( const long int & CMN_UNUSEDvalue)
inline

◆ IsNaN() [6/13]

bool cmnTypeTraits< longlongint >::IsNaN ( const long long int & CMN_UNUSEDvalue)
inline

◆ IsNaN() [7/13]

bool cmnTypeTraits< short >::IsNaN ( const short & CMN_UNUSEDvalue)
inline

◆ IsNaN() [8/13]

template<class _elementType>
CISST_EXPORT bool cmnTypeTraits< _elementType >::IsNaN ( const Type & value)
static

Test if the value is nan.

◆ IsNaN() [9/13]

bool cmnTypeTraits< unsignedchar >::IsNaN ( const unsigned char & CMN_UNUSEDvalue)
inline

◆ IsNaN() [10/13]

bool cmnTypeTraits< unsignedint >::IsNaN ( const unsigned int & CMN_UNUSEDvalue)
inline

◆ IsNaN() [11/13]

bool cmnTypeTraits< unsignedlongint >::IsNaN ( const unsigned long int & CMN_UNUSEDvalue)
inline

◆ IsNaN() [12/13]

bool cmnTypeTraits< unsignedlonglongint >::IsNaN ( const unsigned long long int & CMN_UNUSEDvalue)
inline

◆ IsNaN() [13/13]

bool cmnTypeTraits< unsignedshort >::IsNaN ( const unsigned short & CMN_UNUSEDvalue)
inline

◆ MaxNegativeValue()

template<class _elementType>
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).

◆ MaxPositiveValue()

template<class _elementType>
CISST_EXPORT Type cmnTypeTraits< _elementType >::MaxPositiveValue ( void )
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. */ inline static Type PlusInfinityOrMax(void) { return (HasInfinity()) ? PlusInfinity() : MaxPositiveValue(); }

/*! Return a negative number which is infinity, if available, or the smallest possible negative value otherwise. This function is useful for ``idempotent max'' operation. */ inline static Type MinusInfinityOrMin(void) { return (HasInfinity()) ? MinusInfinity() : MinNegativeValue(); }

/*! The greatest positive value possible for the type.

◆ MinNegativeValue()

template<class _elementType>
CISST_EXPORT Type cmnTypeTraits< _elementType >::MinNegativeValue ( void )
static

The smallest negative value possible for the type, that is, the negative value of greatest magnitude.

◆ MinPositiveValue()

template<class _elementType>
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).

◆ MinusInfinity()

template<class _elementType>
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.

◆ NaN()

template<class _elementType>
CISST_EXPORT Type cmnTypeTraits< _elementType >::NaN ( void )
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.

◆ PlusInfinity()

template<class _elementType>
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.

◆ SetTolerance()

template<class _elementType>
void cmnTypeTraits< _elementType >::SetTolerance ( Type tolerance)
inlinestatic

Set the numerical tolerance for this type.

◆ Tolerance()

template<class _elementType>
Type cmnTypeTraits< _elementType >::Tolerance ( void )
inlinestatic

Return the numerical tolerance value for computation results.

◆ TypeName()

template<class _elementType>
CISST_EXPORT std::string cmnTypeTraits< _elementType >::TypeName ( void )
static

The name of the type.

Member Data Documentation

◆ DefaultTolerance

template<class _elementType>
CISST_EXPORT const Type cmnTypeTraits< _elementType >::DefaultTolerance
static

The tolerance for the specific type.


The documentation for this class was generated from the following file: