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

std::is_compound

Defined in header <type_traits>

template< class T > struct is_compound;

(since C++11)

如果T是复合类型%28,即数组、函数、对象指针、函数指针、成员对象指针、成员函数指针、引用、类、联合或枚举(包括任何cv限定变量%29)提供成员常量。value平等true.对于任何其他类型,valuefalse...

模板参数

T

-

a type to check

辅助变量模板

template< class T > inline constexpr bool is_compound_v = is_compound<T>::value;

(since C++17)

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

成员常数

value static

true if T is a compound 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>

注记

复合类型是从基本类型构造的类型。任何C++类型要么是基本类型,要么是复合类型。

可能的实施

模板<class T>结构是[医]复合:STD::整数[医]常数<bool,%21std::is[医]基本<T>*价值>{};

*。

二次

代码语言:javascript
复制
#include <iostream>
#include <type_traits>
 
int main() {
    class cls {};
    std::cout << (std::is_compound<cls>::value
                     ? "T is compound"
                     : "T is not a compound") << '\n';
    std::cout << (std::is_compound<int>::value
                     ? "T is compound"
                     : "T is not a compound") << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
T is compound
T is not a compound

二次

另见

is_fundamental (C++11)

checks if a type is fundamental type (class template)

is_scalar (C++11)

checks if a type is scalar type (class template)

is_object (C++11)

checks if a type is object type (class template)

is_array (C++11)

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

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

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

扫码关注腾讯云开发者

领取腾讯云代金券