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

std::is_array

Defined in header <type_traits>

template< class T > struct is_array;

(since C++11)

检查是否T是数组类型。提供成员常量。value等于true,如果T是数组类型。否则,value等于false...

模板参数

T

-

a type to check

辅助变量模板

template< class T > inline constexpr bool is_array_v = is_array<T>::value;

(since C++17)

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

成员常数

value static

true if T is an array 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::false[医]类型{};模板<class T>结构是[医]数组<T。[]>:std::true[医]类型{};模板<类T,std::size[医]tN>struct是[医]数组<Tn>:STD::真[医]{}型;

*。

二次

代码语言:javascript
复制
#include <iostream>
#include <type_traits>
 
class A {};
 
int main() 
{
    std::cout << std::boolalpha;
    std::cout << std::is_array<A>::value << '\n';
    std::cout << std::is_array<A[]>::value << '\n';
    std::cout << std::is_array<A[3]>::value << '\n';
    std::cout << std::is_array<float>::value << '\n';
    std::cout << std::is_array<int>::value << '\n';
    std::cout << std::is_array<int[]>::value << '\n';
    std::cout << std::is_array<int[3]>::value << '\n';
}

二次

产出:

二次

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

二次

另见

rank (C++11)

obtains the number of dimensions of an array type (class template)

extent (C++11)

obtains the size of an array type along a specified dimension (class template)

remove_extent (C++11)

removes one extent from the given array type (class template)

remove_all_extents (C++11)

removes all extents from the given array type (class template)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券