名前空間
変種
操作

std::is_bounded_array

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)
is_bounded_array
(C++20)
型特性定数
メタ関数
(C++17)
サポートされている操作
関係とプロパティクエリ
型の変更
(C++11)(C++11)(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 is_bounded_array;
(C++20以降)

std::is_bounded_arrayUnaryTypeTrait です。

T が境界付きの配列型であるかをチェックします。T が境界付きの配列型である場合、true と等しいメンバー定数 value を提供します。そうでない場合、valuefalse と等しくなります。

プログラムが std::is_bounded_array または std::is_bounded_array_v の特殊化を追加した場合、その動作は未定義です。

目次

[編集] テンプレートパラメータ

T - チェックする型

[編集] ヘルパー変数テンプレート

template< class T >
constexpr bool is_bounded_array_v = is_bounded_array<T>::value;
(C++20以降)

std::integral_constant から継承

メンバ定数

value
[static]
T が境界付きの配列型の場合 true、そうでない場合 false
(公開静的メンバ定数)

メンバ関数

operator bool
オブジェクトを bool に変換し、value を返します。
(public member function)
operator()
(C++14)
value を返します。
(public member function)

メンバ型

定義
value_type bool
type std::integral_constant<bool, value>

[編集] 可能な実装

template<class T>
struct is_bounded_array : std::false_type {};
 
template<class T, std::size_t N>
struct is_bounded_array<T[N]> : std::true_type {};

[編集] 備考

機能テストマクロ 規格 機能
__cpp_lib_bounded_array_traits 201902L (C++20) std::is_bounded_arraystd::is_unbounded_array

[編集]

#include <iostream>
#include <type_traits>
 
#define OUT(...) std::cout << #__VA_ARGS__ << " : " << __VA_ARGS__ << '\n'
 
class A {};
 
int main()
{
    std::cout << std::boolalpha;
    OUT(std::is_bounded_array_v<A>);
    OUT(std::is_bounded_array_v<A[]>);
    OUT(std::is_bounded_array_v<A[3]>);
    OUT(std::is_bounded_array_v<float>);
    OUT(std::is_bounded_array_v<int>);
    OUT(std::is_bounded_array_v<int[]>);
    OUT(std::is_bounded_array_v<int[3]>);
}

出力

std::is_bounded_array_v<A> : false
std::is_bounded_array_v<A[]> : false
std::is_bounded_array_v<A[3]> : true
std::is_bounded_array_v<float> : false
std::is_bounded_array_v<int> : false
std::is_bounded_array_v<int[]> : false
std::is_bounded_array_v<int[3]> : true

[編集] 関連項目

(C++11)
型が配列型であるかをチェックする
(クラステンプレート) [編集]
型が未知の境界を持つ配列型であるかをチェックする
(クラステンプレート) [編集]
(C++11)
指定された次元に沿った配列型のサイズを取得する
(クラステンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)