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

另请参阅

<type_traits>
is_signed 类