std::vector<bool>
![]() | This page has been machine-translated from the English version of the wiki using Google Translate. The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
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.
[modifier]Types de membres
Type du membre | Définition |
value_type | bool |
allocator_type | Allocator |
size_type | Défini par l'implémentation |
difference_type | Défini par l'implémentation |
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 |
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. |
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. |
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. |
const_iterator | Défini par l'implémentation |
reverse_iterator | std::reverse_iterator<iterator> |
const_reverse_iterator | std::reverse_iterator<const_iterator> |
[modifier]Fonctions membres
Construit le vector (fonction membre publique de std::vector ) | |
détruit le vector (fonction membre publique de std::vector ) | |
Attribue les valeurs dans le conteneur (fonction membre publique de std::vector ) | |
Attribue les valeurs dans le conteneur | |
Renvoie l'allocateur associé | |
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 ) | |
accède à l'élément spécifié (fonction membre publique de std::vector ) | |
accède au premier élément (fonction membre publique de std::vector ) | |
accède au dernier élément (fonction membre publique de std::vector ) | |
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 ) | |
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 ) | |
retourne un itérateur inversé au début (fonction membre publique de std::vector ) | |
retourne un itérateur inversé à la fin (fonction membre publique de std::vector ) | |
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 ) | |
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 ) | |
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 ) | |
réserve de l'espace mémoire (fonction membre publique de std::vector ) | |
renvoie le nombre d'éléments qui peuvent être contenus dans l'espace mémoire actuellement alloué (fonction membre publique de std::vector ) | |
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 ) | |
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 ) | |
efface des éléments (fonction membre publique de std::vector ) | |
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 ) | |
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 ) | |
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 ) | |
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 ) | |
vector<bool> modificateurs spécifiquesOriginal: vector<bool> specific modifiersThe 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) | |
[ 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>::reference sOriginal: swaps two std::vector<bool>::reference sThe 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) |
[modifier]Fonctions annexes
compare lexicographiquement les valeurs dans le vector Original: lexicographically compares the values in the vector The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) | |
l'algorithme spécialisé std::swap Original: specializes the std::swap algorithm The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction générique) |
[modifier]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>
.