首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::is_object

Defined in header <type_traits>

template< class T > struct is_object;

(since C++11)

如果T是对象类型%28,这可能是cv限定类型,但函数、引用或void类型%29,提供成员常量value平等true.对于任何其他类型,valuefalse...

模板参数

T

-

a type to check

辅助变量模板

template< class T > inline constexpr bool is_object_v = is_object<T>::value;

(since C++17)

继承自STD:积分[医]常量

成员常数

value static

true if T is an object 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>

可能的实施

模板<class T>结构是[医]目的:STD::整数[医]常数<bool,std::is[医]标量<T>*价值STD::是[医]列阵<T>*价值STD::是[医]联合<T>*价值STD::是[医]类<T>*价值>{};

*。

二次

代码语言:javascript
复制
#include <iostream>
#include <type_traits>
 
int main() {
    class cls {};
    std::cout << std::boolalpha;
    std::cout << std::is_object<int>::value << '\n';
    std::cout << std::is_object<int&>::value << '\n';
    std::cout << std::is_object<cls>::value << '\n';
    std::cout << std::is_object<cls&>::value << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
true
false
true
false

二次

另见

is_scalar (C++11)

checks if a type is scalar type (class template)

is_array (C++11)

checks if a type is an array type (class template)

is_union (C++11)

checks if a type is an union type (class template)

is_class (C++11)

checks if a type is a non-union class type (class template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券