std::remove_all_extents
| Defined in header <type_traits> |  |  | 
|---|---|---|
| template< class T > struct remove_all_extents; |  | (since C++11) | 
如果T是某种类型的多维数组。X,提供成员类型为type等于X,否则type是T...
成员类型
| 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>*类型;};
*。
例
二次
#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);
}二次
产出:
二次
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) | 
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

