is_unsigned 類別
測試類型是否為不帶正負號的整數。
語法
template <class Ty>
struct is_unsigned;
參數
Ty
要查詢的類型。
備註
如果類型 Ty 是未帶正負號整數類型或cv-qualified
未帶正負號整數型別,則類型述詞的實例會保留 true,否則為 false。
範例
// std__type_traits__is_unsigned.cpp
// compile with: /EHsc
#include <type_traits>
#include <iostream>
struct trivial
{
int val;
};
int main()
{
std::cout << "is_unsigned<trivial> == " << std::boolalpha
<< std::is_unsigned<trivial>::value << std::endl;
std::cout << "is_unsigned<int> == " << std::boolalpha
<< std::is_unsigned<int>::value << std::endl;
std::cout << "is_unsigned<unsigned int> == " << std::boolalpha
<< std::is_unsigned<unsigned int>::value << std::endl;
std::cout << "is_unsigned<float> == " << std::boolalpha
<< std::is_unsigned<float>::value << std::endl;
return (0);
}
is_unsigned<trivial> == false
is_unsigned<int> == false
is_unsigned<unsigned int> == true
is_unsigned<float> == false
需求
標頭:<type_traits>
命名空間:std