std::is_unsigned
| Defined in header <type_traits> |  |  | 
|---|---|---|
| template< class T > struct is_unsigned; |  | (since C++11) | 
如果T是算术类型,提供成员常量。value平等true如果T(0) < T(-1)*这导致true对于无符号整数类型和类型bool和在false对于有符号整数类型和浮点类型.
对于任何其他类型,value是false...
模板参数
| T | - | a type to check | 
|---|
辅助变量模板
| template< class T > inline constexpr bool is_unsigned_v = is_unsigned<T>::value; |  | (since C++17) | 
|---|
继承自STD:积分[医]常量
成员常数
| value static | true if T is an unsigned arithmetic type , false otherwise (public static member constant) | 
|---|
成员函数
| operator bool | converts the object to bool, returns value (public member function) | 
|---|---|
| operator() (C++14) | returns value (public member function) | 
成员类型
| Type | Definition | 
|---|---|
| value_type | bool | 
| type | std::integral_constant<bool, value> | 
可能的实施
名称空间详细信息{Template<type Name T,bool=std::is[医]算术<T>*值>结构是[医]未签名:STD::整数[医]常数<bool,T%280%29<T%28-1%29>{};模板<typename T>结构是[医]无符号<T,false>:std::false[医]类型{};}//名称空间详细模板<typename T>结构是[医]未签名:详细信息::is[医]未签名<T>*{}型;
*。
例
二次
#include <iostream>
#include <type_traits>
 
class A {};
enum B : unsigned {};
enum class C : unsigned {};
 
int main() 
{
    std::cout << std::boolalpha;
    std::cout << std::is_unsigned<A>::value << '\n';
    std::cout << std::is_unsigned<float>::value << '\n';
    std::cout << std::is_unsigned<signed int>::value << '\n';
    std::cout << std::is_unsigned<unsigned int>::value << '\n';
    std::cout << std::is_unsigned<B>::value << '\n';
    std::cout << std::is_unsigned<C>::value << '\n';
}二次
产出:
二次
false
false
false
true
false
false二次
另见
| is_signed (C++11) | checks if a type is signed arithmetic type (class template) | 
|---|---|
| is_arithmetic (C++11) | checks if a type is arithmetic type (class template) | 
| make_signed (C++11) | makes the given integral type signed (class template) | 
| make_unsigned (C++11) | makes the given integral type unsigned (class template) | 
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

