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

std::remove_all_extents

Defined in header <type_traits>

?

?

template< class T > struct remove_all_extents;

?

(since C++11)

如果T是某种类型的多维数组。X,提供成员类型为type等于X,否则typeT...

成员类型

Name

Definition

type

the type of the element of T

帮助者类型

template< class T > using remove_all_extents_t = typename remove_all_extents<T>::type;

?

(since C++14)

可能的实施

模板<class T>结构拆卸[医]全[医]区{tydufT类型;};模板<class T>结构拆卸[医]全[医]范围<T。[]>{tydurif type Name移除[医]全[医]范围<T>*类型;};模板<类T,std::size[医]TN>结构删除[医]全[医]范围<Tn>{tydurif type Name移除[医]全[医]范围<T>*类型;};

*。

二次

代码语言:javascript
复制
#include <iostream>
#include <type_traits>
#include <typeinfo>
 
template<class A>
void foo(const A&)
{
    typedef typename std::remove_all_extents<A>::type Type;
    std::cout << "underlying type: " << typeid(Type).name() << '\n';
}
 
int main()
{
    float a1[1][2][3];
    int a2[3][2];
    float a3[1][1][1][1][2];
    double a4[2][3];
 
    foo(a1);
    foo(a2);
    foo(a3);
    foo(a4);
}

二次

产出:

二次

代码语言:javascript
复制
underlying type: f
underlying type: i
underlying type: f
underlying type: d

二次

另见

is_array (C++11)

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

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)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com