Difference between revisions of "cpp/container/vector bool"
From cppreference.com
m (r2.7.3) (Robot: Adding de, es, fr, it, ja, pt, ru, zh) |
(added std::hash link) |
||
Line 78: | Line 78: | ||
{{dcl list template | cpp/container/dcl list operator_cmp | vector}} | {{dcl list template | cpp/container/dcl list operator_cmp | vector}} | ||
{{dcl list template | cpp/container/dcl list swap2 | vector}} | {{dcl list template | cpp/container/dcl list swap2 | vector}} | ||
+ | {{dcl list end}} | ||
+ | |||
+ | ===Helper classes=== | ||
+ | {{dcl list begin}} | ||
+ | {{dcl list template | cpp/container/vector_bool/dcl list hash}} | ||
{{dcl list end}} | {{dcl list end}} | ||
Revision as of 15:27, 28 December 2012
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.
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 a byte-sized bool.
std::vector<bool> behaves similarly to std::vector, but in order to be space efficient, it:
- 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 |
Member types
Member functions
Non-member functions
Helper classes
Notes
If the size of the bitset is known at compile time, std::bitset may be used, which offers a richer set of member functions. In addition, boost::dynamic_bitset exists as an alternative to std::vector<bool>
.