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
Défini dans l'en-tête <type_traits>
template < class T >
struct is_bounded_array ;
(depuis C++20)

std::is_bounded_array est un UnaryTypeTrait .

Vérifie si T est un type tableau de taille connue. Fournit la constante membre value qui est égale à true si T est un type tableau de taille connue. Sinon, value est égale à false .

Si le programme ajoute des spécialisations pour std::is_bounded_array ou std::is_bounded_array_v , le comportement est indéfini.

Table des matières

Paramètres du modèle

T - un type à vérifier

Modèle de variable d'assistance

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

Hérité de std:: integral_constant

Constantes membres

value
[static]
true si T est un type tableau de taille connue, false sinon
(constante membre publique statique)

Fonctions membres

operator bool
convertit l'objet en bool , retourne value
(fonction membre publique)
operator()
(C++14)
retourne value
(fonction membre publique)

Types membres

Type Définition
value_type bool
type std:: integral_constant < bool , value >

Implémentation possible

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

Notes

Macro de test de fonctionnalité Valeur Norme Fonctionnalité
__cpp_lib_bounded_array_traits 201902L (C++20) std::is_bounded_array , std::is_unbounded_array

Exemple

#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]>);
}

Sortie :

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

Voir aussi

(C++11)
vérifie si un type est un type tableau
(modèle de classe)
vérifie si un type est un type tableau de taille inconnue
(modèle de classe)
(C++11)
obtient la taille d'un type tableau selon une dimension spécifiée
(modèle de classe)