Namespaces
Variants

std:: is_bounded_array

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)
is_bounded_array
(C++20)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
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 is_bounded_array ;
(C++20以降)

std::is_bounded_array UnaryTypeTrait です。

T が既知の境界を持つ配列型かどうかをチェックします。 メンバー定数 value を提供します。 T が既知の境界を持つ配列型の場合、 value true に等しくなります。 それ以外の場合、 value false に等しくなります。

プログラムが 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]
true T が既知の境界を持つ配列型の場合、 false それ以外の場合
(public static member constant)

メンバ関数

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_array , std::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)
指定された次元に沿った配列型のサイズを取得する
(クラステンプレート)