is_signed 類別
測試類型是否為帶正負號的整數。
語法
template <class Ty>
struct is_signed;
參數
Ty
要查詢的類型。
備註
如果類型 Ty 是帶正負號整數類型或cv-qualified
帶正負號整數型別,則類型述詞的實例會保留 true,否則為 false。
範例
// std__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);
}
is_signed<trivial> == false
is_signed<int> == true
is_signed<unsigned int> == false
is_signed<float> == true
需求
標頭:<type_traits>
命名空間:std