ecl_type_traits Documentation

ecl_type_traits

Extends c++ type traits and implements a few more to boot.

Embedded Control Library

    Provides some cross platform type traits above and beyond what is provided
    by c++.

Compiling & Linking

    Include the following at the top of any translation unit which
    requires this library:
// The error interfaces

You will also need to link to -lecl_type_traits.

Usage

Numeric Limits

    This extends c++'s numeric_limits class for fundamental types, providing in addition, static constants
    that can be utilised as template arguments (as opposed to c macros or c++ functions in numeric_limits).
    For integral types, an example of the extras available:
ecl::uint16 bits = NumericLimits<int>::bits;
ecl::uint16 bytes = NumericLimits<int>::bytes;
int j = NumericLimits<int>::one;
int i = NumericLimits<int>::minimum;
int k = NumericLimits<int>::maximum;

An example of some extras for a float type:

ecl::uint16 bits = NumericLimits<float>::bits;
ecl::uint16 bytes = NumericLimits<float>::bytes;
// precision setting is a rough, but useful aid to bounding the accuracy for some math calculations
NumericLimits<float>::Precision p = NumericLimits<float>::dummy_precision();
// note, numeric_limits<float>::min() is the smallest
// positive value, this is the smallest negative value.
float minimum = NumericLimits<float>::minimum;
float maximum = NumericLimits<float>::maximum;
    Note that it inherits the numeric_limits class, so all the functions therein can also be used.

Fundamental Type Traits

    These are in the upcoming C++0x standard, so are only a temporary feature in the ecl. They 
    are a subset and work just like boosts type traits. More will be added as needed. The 
    code snippet below is for runtime code, but they're actually more useful with enable_if
    in determining which compile time template specialisations to instantiate.
if ( is_float<double>::value ) {
// take some action
}

The current list of type traits include:

Unit Tests

    - src/test/numeric_limits.cpp
    - src/test/fundamental_types.cpp

ChangeLog

    - <b>Mar 11</b> : added the is_xxx_byte type traits.
    - <b>Feb 11</b> : collected type traits from ecl_config and ecl_mpl.
    - <b>Sep 10</b> : @ref ecl::is_byte "is_byte" trait for detection of single byte types added.
    - <b>Aug 10</b> : @ref ecl::is_signed "is_signed", @ref ecl::is_unsigned "is_unsigned" trait types added.
    - <b>Jul 10</b> : @ref ecl::is_integral "is_integral", @ref ecl::is_float "is_float" trait types added.


ecl_type_traits
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:18