std::vector<bool> is a possibly space-efficient specialization of std::vector for the type bool.
The manner in which std::vector<bool> is made space efficient (as well as whether it is optimized at all) is implementation defined. One potential optimization involves coalescing vector elements such that each element occupies a single bit instead of sizeof(bool) bytes.
std::vector<bool> behaves similarly to std::vector, but in order to be space efficient, it:
(constructor)
constructs the vector
(public member function of std::vector<T,Allocator>
)
(destructor)
destructs the vector
(public member function of std::vector<T,Allocator>
)
operator=
assigns values to the container
(public member function of std::vector<T,Allocator>
)
assign
assigns values to the container
(public member function of std::vector<T,Allocator>
)
get_allocator
returns the associated allocator
(public member function of std::vector<T,Allocator>
)
Element access
at
access specified element with bounds checking
(public member function of std::vector<T,Allocator>
)
operator[]
access specified element
(public member function of std::vector<T,Allocator>
)
front
access the first element
(public member function of std::vector<T,Allocator>
)
back
access the last element
(public member function of std::vector<T,Allocator>
)
Iterators
begin
cbegin
(C++11)
returns an iterator to the beginning
(public member function of std::vector<T,Allocator>
)
end
cend
(C++11)
returns an iterator to the end
(public member function of std::vector<T,Allocator>
)
rbegin
crbegin
(C++11)
returns a reverse iterator to the beginning
(public member function of std::vector<T,Allocator>
)
rend
crend
(C++11)
returns a reverse iterator to the end
(public member function of std::vector<T,Allocator>
)
Capacity
empty
checks whether the container is empty
(public member function of std::vector<T,Allocator>
)
size
returns the number of elements
(public member function of std::vector<T,Allocator>
)
max_size
returns the maximum possible number of elements
(public member function of std::vector<T,Allocator>
)
reserve
reserves storage
(public member function of std::vector<T,Allocator>
)
capacity
returns the number of elements that can be held in currently allocated storage
(public member function of std::vector<T,Allocator>
)
Modifiers
clear
clears the contents
(public member function of std::vector<T,Allocator>
)
insert
inserts elements
(public member function of std::vector<T,Allocator>
)
emplace
(C++11)
constructs element in-place
(public member function of std::vector<T,Allocator>
)
erase
erases elements
(public member function of std::vector<T,Allocator>
)
push_back
adds an element to the end
(public member function of std::vector<T,Allocator>
)
emplace_back
(C++11)
constructs an element in-place at the end
(public member function of std::vector<T,Allocator>
)
pop_back
removes the last element
(public member function of std::vector<T,Allocator>
)
resize
changes the number of elements stored
(public member function of std::vector<T,Allocator>
)
swap
swaps the contents
(public member function of std::vector<T,Allocator>
)
vector<bool>
specific modifiers
flip
flips all the bits
(public member function)
swap
[static]
swaps two std::vector<bool>::reference
s
(public static member function)