Extends c++ type traits and implements a few more to boot.
Provides some cross platform type traits above and beyond what is provided by c++.
Include the following at the top of any translation unit which requires this library:
You will also need to link to -lecl_type_traits.
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:
An example of some extras for a float type:
Note that it inherits the numeric_limits class, so all the functions therein can also be used.
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.
The current list of type traits include:
- src/test/numeric_limits.cpp - src/test/fundamental_types.cpp
- <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.