is_signed 类
测试,如果类型是带符号整数。
template<class Ty>
struct is_signed;
参数
- Ty
查询的类型。
备注
谓词应用类型的实例,则 Ty 类型是带符号的整数类型或 cv-qualified 符号的整数类型,否则它对负错误。
示例
// std_tr1__type_traits__is_signed.cpp
// compile with: /EHsc
#include <type_traits>
#include <iostream>
struct trivial
{
int val;
};
int main()
{
std::cout << "is_signed<trivial> == " << std::boolalpha
<< std::is_signed<trivial>::value << std::endl;
std::cout << "is_signed<int> == " << std::boolalpha
<< std::is_signed<int>::value << std::endl;
std::cout << "is_signed<unsigned int> == " << std::boolalpha
<< std::is_signed<unsigned int>::value << std::endl;
std::cout << "is_signed<float> == " << std::boolalpha
<< std::is_signed<float>::value << std::endl;
return (0);
}
要求
标头: <type_traits>
命名空间: std