Differences between std::is_integer and std::is_integral?

xmllmx picture xmllmx · Feb 3, 2013 · Viewed 7.4k times · Source

C++11 provides two type trait template classes: std::is_integer and std::is_integral. However, I cannot tell the differences between them.

What type, say T, can make std::is_integer<T>::value true and make std::is_integral<T>::value false?

Answer

Howard Hinnant picture Howard Hinnant · Feb 3, 2013

std::is_integer<T> does not exist.

That being said, std::numeric_limits<T>::is_integer does exist.

I'm not aware of any significant difference between std::numeric_limits<T>::is_integer and std::is_integral<T>. The latter was designed much later and became standard in C++11, whereas the former was introduced in C++98.