ALPS Project

Header file typetraits.h

This header contains traits classes for standard types.

Synopsis

namespace alps {
typedef ... type_tag_t;
template <class T> struct TypeTraits;

template <> struct TypeTraits<int8_t>;
template <> struct TypeTraits<uint8_t>;
template <> struct TypeTraits<int16_t>;
template <> struct TypeTraits<uint16_t>;
template <> struct TypeTraits<int32_t>;
template <> struct TypeTraits<uint32_t>;
template <> struct TypeTraits<int64_t>;
template <> struct TypeTraits<uint64_t>;
template <> struct TypeTraits<float>;
template <> struct TypeTraits<double>;
template <> struct TypeTraits<long double>;
template <> struct TypeTraits<std::complex<float> >;
template <> struct TypeTraits<std::complex<double> >;
template <> struct TypeTraits<std::complex<long double> >;
template <> struct TypeTraits<bool>;
template <> struct TypeTraits<std::string>;

template <class T> struct NumericTypeConversion;
}

The TypeTraits traits class

The TypeTraits traits class encodes useful type properties not yet found in the standard library nor boost.
Member Type Description
TypeTraits<T>::is_specializedbool true if the template has been specialized for the template parameter
TypeTraits<T>::is_complexbool true if the type T is complex
TypeTraits<T>::type_tagpalm::type_tag_t a unique integral identifier for all types for which the template has been specialized
TypeTraits<T>::norm_t type to store the norm of a number of typeT
TypeTraits<T>::average_t type to store averages of numbers of typeT
TypeTraits<T>::signed_t for integral types, the signed version of the type T, otherwise the type itself
TypeTraits<T>::unsigned_t for integral types, the unsigned version of the type T, otherwise the type itself
TypeTraits<T>::real_t for complex types, the real base type of type T, otherwise the type itself
TypeTraits<T>::epsilon() the machine precision of TypeTraits<T>::norm_t

The NumericTypeConversion traits class

The NumericTypeConversion traits class helps reduce code proliferation by reducing the number of types for which a template needs to be instantiated.
 NumericTypeConversion<T,X>::appropriate_type
The appropriate_type is a type to which X can be converted without loss of precision when afterwards a numeric operation with type T is planned. As there are far fewer appropriate_types than types T code proliferation can be reduced.
copyright (c) 1994-2003 by Matthias Troyer