◐ Shell
clean mode source ↗

std::vector<bool> — cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

Déclaré dans l'en-tête

<vector>

template<class Allocator = std::allocator<bool>> class vector<bool, Allocator>;

std::vector<bool> est une spécialisation plus efficace en espace de std::vector pour le type bool.

La manière dont std::vector<bool> est rendu efficace en espace (ainsi que le fait qu'elle est optimisée ou pas) dépend de l'implémentation. Une optimisation potentielle consiste à fusionner des éléments du vecteur de sorte que chaque bit n'occupe qu'un seul bit réel au lieu d'un bool de la taille d'un octet.

std::vector<bool> se comporte comme std::vector, mais pour être efficace en espace, il :

  • Ne stocke pas nécessairement ses données dans un seul bloc contigu de mémoire.
  • Expose std::vector<bool>::reference comme méthode d'accès à des bits individuels.
  • N'utilise pas std::allocator_traits::construct pour construire des bits.

Types de membres

Type du membre Définition
value_type bool [edit]
allocator_type Allocator [edit]
size_type Défini par l'implémentation[edit]
difference_type Défini par l'implémentation [edit]

classe proxy qui représente une référence à un seul bool

Original:

proxy class representing a reference to a single bool

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(classe)
const_reference bool [edit]
pointer

défini par l'implémentation

Original:

implementation-defined

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[edit]
const_pointer

défini par l'implémentation

Original:

implementation-defined

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[edit]
iterator

défini par l'implémentation

Original:

implementation-defined

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[edit]
const_iterator Défini par l'implémentation[edit]
reverse_iterator std::reverse_iterator<iterator> [edit]
const_reverse_iterator std::reverse_iterator<const_iterator> [edit]

Fonctions membres

Construit le vector
(fonction membre publique de std::vector) [edit]
détruit le vector
(fonction membre publique de std::vector) [edit]
Attribue les valeurs dans le conteneur
(fonction membre publique de std::vector) [edit]

Attribue les valeurs dans le conteneur
(fonction membre publique de std::vector) [edit]

Renvoie l'allocateur associé
(fonction membre publique de std::vector) [edit]

Elément d'accès

Original:

Element access

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

accède à l'élément spécifié avec vérification de bornes
(fonction membre publique de std::vector) [edit]
accède à l'élément spécifié
(fonction membre publique de std::vector) [edit]
accède au premier élément
(fonction membre publique de std::vector) [edit]
accède au dernier élément
(fonction membre publique de std::vector) [edit]

Les itérateurs

Original:

Iterators

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

retourne un itérateur au début

Original:

returns an iterator to the beginning

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]

retourne un itérateur à la fin

Original:

returns an iterator to the end

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]
retourne un itérateur inversé au début
(fonction membre publique de std::vector) [edit]
retourne un itérateur inversé à la fin
(fonction membre publique de std::vector) [edit]

Capacité

Original:

Capacity

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

vérifie si le conteneur est vide

Original:

checks whether the container is empty

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]

retourne le nombre d'éléments

Original:

returns the number of elements

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]

retourne le plus grand nombre possible d'éléments

Original:

returns the maximum possible number of elements

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]
réserve de l'espace mémoire
(fonction membre publique de std::vector) [edit]
renvoie le nombre d'éléments qui peuvent être contenus dans l'espace mémoire actuellement alloué
(fonction membre publique de std::vector) [edit]

Modificateurs

Original:

Modifiers

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

efface le contenu

Original:

clears the contents

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]

insère des éléments

Original:

inserts elements

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]
efface des éléments
(fonction membre publique de std::vector) [edit]

ajoute des éléments à la fin

Original:

adds elements to the end

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]

supprime le dernier élément

Original:

removes the last element

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]

modifie le nombre d'éléments stockés

Original:

changes the number of elements stored

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]

permute les contenus

Original:

swaps the contents

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique de std::vector) [edit]

vector<bool> modificateurs spécifiques

Original:

vector<bool> specific modifiers

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

inverse tous les bits
(fonction membre publique) [edit]

[

statique

Original:

static

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

]

Echange deux std::vector<bool>::references

Original:

swaps two std::vector<bool>::references

The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.


(fonction membre publique statique) [edit]

Fonctions annexes

Notes

Si la taille du champ de bits est connue au moment de la compilation, std::bitset peut être utilisé, car il offre un ensemble plus riche de fonctions membres. En outre, il existe boost::dynamic_bitset comme alternative à std::vector<bool>.