Namespaces
Variants

std:: remove_all_extents

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
remove_all_extents
(C++11)

Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더에 정의됨 <type_traits>
template < class T >
struct remove_all_extents ;
(C++11부터)

만약 T 가 어떤 타입 X 의 다차원 배열인 경우, type 멤버 typedef를 X 와 동일하게 제공하며, 그렇지 않은 경우 type T 입니다.

프로그램이 std::remove_all_extents 에 대한 특수화를 추가하는 경우, 동작은 정의되지 않습니다.

목차

멤버 타입

이름 정의
type T 요소의 타입

헬퍼 타입

template < class T >
using remove_all_extents_t = typename remove_all_extents < T > :: type ;
(C++14 이후)

가능한 구현

template<class T>
struct remove_all_extents { typedef T type; };
template<class T>
struct remove_all_extents<T[]> {
    typedef typename remove_all_extents<T>::type type;
};
template<class T, std::size_t N>
struct remove_all_extents<T[N]> {
    typedef typename remove_all_extents<T>::type type;
};

예제

#include <iostream>
#include <type_traits>
#include <typeinfo>
template<class A>
void info(const A&)
{
    typedef typename std::remove_all_extents<A>::type Type;
    std::cout << "underlying type: " << typeid(Type).name() << '\n';
}
int main()
{
    float a0;
    float a1[1][2][3];
    float a2[1][1][1][1][2];
    float* a3;
    int a4[3][2];
    double a5[2][3];
    struct X { int m; } x0[3][3];
    info(a0);
    info(a1);
    info(a2);
    info(a3);
    info(a4);
    info(a5);
    info(x0);
}

가능한 출력:

underlying type: float
underlying type: float
underlying type: float
underlying type: float*
underlying type: int
underlying type: double
underlying type: main::X

참고 항목

(C++11)
타입이 배열 타입인지 확인합니다
(클래스 템플릿)
(C++11)
배열 타입의 차원 수를 구합니다
(클래스 템플릿)
(C++11)
지정된 차원을 따라 배열 타입의 크기를 구합니다
(클래스 템플릿)
주어진 배열 타입에서 하나의 차원을 제거합니다
(클래스 템플릿)