std :: is_integer和std :: is_integral之间的区别?

问题描述:

C ++ 11提供了两个类型特征模板类:std::is_integerstd::is_integral.但是,我无法分辨它们之间的区别.

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

哪种类型(例如T)可以使std::is_integer<T>::value为真,而使std::is_integral<T>::value为假?

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

std::is_integer<T>不存在.

话虽这么说,std::numeric_limits<T>::is_integer确实存在.

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

我不知道std::numeric_limits<T>::is_integerstd::is_integral<T>之间的任何显着差异.后者的设计要晚得多,并且在C ++ 11中成为标准,而前者是在C ++ 98中引入的.

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.