std::is_compound
STD::是[医]复配
Defined in header | | |
---|---|---|
template< class T > struct is_compound; | | (since C++11) |
如果T
是复合类型%28,即数组、函数、对象指针、函数指针、成员对象指针、成员函数指针、引用、类、联合或枚举(包括任何cv限定变量%29)提供成员常量。value
平等true
.对于任何其他类型,value
是false
...
模板参数
T | - | a type to check |
---|
辅助变量模板
template< class T > inline constexpr bool is_compound_v = is_compound | | (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>*价值>{};
*。
例
二次
#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';
}
二次
产出:
二次
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) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。