Namespaces
Variants
Views
Actions

std::vector<bool>

From cppreference.com
Defined in header <vector>
template<class Allocator = std::allocator<bool>>
class vector<bool, Allocator>;

std::vector<bool> is a space-efficient specialization of std::vector for the type bool.

It behaves similarly to std::vector, but in order to be space efficient, std::vector<bool>:

  • Does not necessarily store its data in a single contiguous chunk of memory.
  • Exposes std::vector<bool>::reference as a method of accessing individual bits.
  • Does not use std::allocator_traits::construct to construct bit values.

Contents

[edit] Member types

Member type Definition
value_type bool [edit]
allocator_type Allocator [edit]
size_type implementation-defined [edit]
difference_type implementation-defined[edit]
proxy class representing a reference to a single bool
(class)
const_reference bool [edit]
pointer implementation-defined[edit]
const_pointer implementation-defined[edit]
iterator implementation-defined [edit]
const_iterator implementation-defined [edit]
reverse_iterator std::reverse_iterator<iterator> [edit]
const_reverse_iterator std::reverse_iterator<const_iterator> [edit]

[edit] Member functions

constructs the vector
(public member function of std::vector) [edit]
destructs the vector
(public member function of std::vector) [edit]
assigns values to the container
(public member function of std::vector) [edit]
assigns values to the container
(public member function of std::vector) [edit]
returns the associated allocator
(public member function of std::vector) [edit]
Element access
access specified element with bounds checking
(public member function of std::vector) [edit]
access specified element
(public member function of std::vector) [edit]
access the first element
(public member function of std::vector) [edit]
access the last element
(public member function of std::vector) [edit]
Iterators
returns an iterator to the beginning
(public member function of std::vector) [edit]
returns an iterator to the end
(public member function of std::vector) [edit]
returns a reverse iterator to the beginning
(public member function of std::vector) [edit]
returns a reverse iterator to the end
(public member function of std::vector) [edit]
Capacity
checks whether the container is empty
(public member function of std::vector) [edit]
returns the number of elements
(public member function of std::vector) [edit]
returns the maximum possible number of elements
(public member function of std::vector) [edit]
reserves storage
(public member function of std::vector) [edit]
returns the number of elements that can be held in currently allocated storage
(public member function of std::vector) [edit]
Modifiers
clears the contents
(public member function of std::vector) [edit]
inserts elements
(public member function of std::vector) [edit]
erases elements
(public member function of std::vector) [edit]
adds elements to the end
(public member function of std::vector) [edit]
removes the last element
(public member function of std::vector) [edit]
changes the number of elements stored
(public member function of std::vector) [edit]
swaps the contents
(public member function of std::vector) [edit]
vector<bool> specific modifiers
flips all the bits
(public member function) [edit]
[static]
swaps two std::bitset<bool>::references
(public static member function) [edit]

[edit] Non-member functions

lexicographically compares the values in the vector
(function template) [edit]
specializes the std::swap algorithm
(function template) [edit]