◐ Shell
clean mode source ↗

std::is_bounded_array - cppreference.com

提供: cppreference.com

<tbody> </tbody>

template< class T > struct is_bounded_array;

(C++20以上)

T が境界の既知な配列型かどうか調べます。 T が境界の既知な配列型であれば、 true に等しいメンバ定数 value が提供されます。 そうでなければ、 valuefalse に等しくなります。

is_bounded_array または is_bounded_array_v に対して特殊化を追加するプログラムは未定義です。

テンプレート引数

ヘルパー変数テンプレート

<tbody> </tbody>

template< class T > inline constexpr bool is_bounded_array_v = is_bounded_array<T>::value;

(C++20以上)

std::integral_constant から継承

メンバ定数

T が境界の既知な配列型であるならば true、そうでなければ false
(パブリック静的メンバ定数)

メンバ関数

オブジェクトを bool に変換します。 value を返します
(パブリックメンバ関数)
value を返します
(パブリックメンバ関数)

メンバ型

定義
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 {};

#include <iostream>
#include <type_traits>

class A {};

int main() 
{
    std::cout << std::boolalpha;
    std::cout << std::is_bounded_array_v<A> << '\n';
    std::cout << std::is_bounded_array_v<A[]> << '\n';
    std::cout << std::is_bounded_array_v<A[3]> << '\n';
    std::cout << std::is_bounded_array_v<float> << '\n';
    std::cout << std::is_bounded_array_v<int> << '\n';
    std::cout << std::is_bounded_array_v<int[]> << '\n';
    std::cout << std::is_bounded_array_v<int[3]> << '\n';
}

出力:

false
false
true
false
false
false
true

関連項目