The C++ standard* states:
Specializations shall be provided for each fundamental type, both floating point and integer, including bool.
(*- I am having trouble finding an earlier draft of the standard. If someone can lend a hand here, it'd be much appreciated.)
Since std::numeric_limits
provides definitions for is_integer
and is_specialized
, you can combine the information to deduce whether or not a type is a floating point type.
For example:
template <typename T>
struct is_floating_point
{
static const bool value;
};
template <typename T>
const bool is_floating_point<T>::value =
std::numeric_limits<T>::is_specialized && // Is fundamental arithmetic type...
!std::numeric_limits<T>::is_integer; // ...that is not an integer