名前空間
変種
操作

std::remove_all_extents

From cppreference.com
< cpp‎ | types
 
 
メタプログラミングライブラリ
型特性
型のカテゴリ
(C++11)
(C++11)(DR*)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11) 
(C++11)
(C++11)
型のプロパティ
(C++11)
(C++11)
(C++14)
(C++11)(C++26で非推奨)
(C++11)(C++20まで*)
(C++11)(C++20で非推奨)
(C++11)
型特性定数
メタ関数
(C++17)
サポートされている操作
関係とプロパティクエリ
型の変更
(C++11)(C++11)(C++11)
remove_all_extents
(C++11)

型の変換
(C++11)(C++23で非推奨)
(C++11)(C++23で非推奨)
(C++11)
(C++11)(C++20まで*)(C++17)

(C++11)
(C++17)
コンパイル時有理数演算
コンパイル時整数シーケンス
 
ヘッダ <type_traits> で定義
template< class T >
struct remove_all_extents;
(C++11以降)

Tが何らかの型Xの多次元配列である場合、メンバ型typeXに等しく提供します。それ以外の場合、typeTです。

プログラムが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)
指定された次元に沿った配列型のサイズを取得する
(クラステンプレート) [編集]
与えられた配列型から1つの次元を削除する
(クラステンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)