名前空間
変種
操作

std::remove_all_extents

提供: cppreference.com
< cpp‎ | types
 
 
ユーティリティライブラリ
汎用ユーティリティ
日付と時間
関数オブジェクト
書式化ライブラリ (C++20)
(C++11)
関係演算子 (C++20で非推奨)
整数比較関数
(C++20)
スワップと型操作
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
一般的な語彙の型
(C++11)
(C++17)
(C++17)
(C++17)
(C++17)

初等文字列変換
(C++17)
(C++17)
 
型サポート
型の性質
(C++11)
(C++11)
(C++14)
(C++11)
(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++11)
(C++17)
(C++11)(C++20未満)(C++17)
 
ヘッダ <type_traits> で定義
template< class T >
struct remove_all_extents;
(C++11以上)

T が何らかの型 X の多次元配列であれば、 X と等しいメンバ型 type が提供されます。 そうでなければ、 typeT です。

目次

[編集] メンバ型

名前 定義
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 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

[編集] 関連項目

(C++11)
型が配列型かどうか調べます
(クラステンプレート) [edit]
(C++11)
配列型の次元数を取得します
(クラステンプレート) [edit]
(C++11)
配列型の指定された次元のサイズを取得します
(クラステンプレート) [edit]
指定された配列型からエクステントを1つ削除します
(クラステンプレート) [edit]