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 type_traits;

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

template <class T> struct NumericTypeConversion;
}

The type_traits traits class

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

Distributed under the Boost Software License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt)