A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/vector/vector-bool/ below:

class template specialization

<vector>

std::vector<bool>
template < class T, class Alloc = allocator<T> > class vector; // generic templatetemplate <class Alloc> class vector<bool,Alloc>;               // bool specialization

Vector of bool

This is a specialized version of vector, which is used for elements of type bool and optimizes for space.

It behaves like the unspecialized version of vector, with the following changes:



These changes provide a quirky interface to this specialization and favor memory optimization over processing (which may or may not suit your needs). In any case, it is not possible to instantiate the unspecialized template of vector for bool directly. Workarounds to avoid this range from using a different type (char, unsigned char) or container (like deque) to use wrapper types or further specialize for specific allocator types.

bitset is a class that provides a similar functionality for fixed-size arrays of bits.



Template parameters
Alloc
Type of the allocator object used to define the storage allocation model. By default, allocator<bool> is used, which defines the simplest memory allocation model and is value-independent.
Aliased as member type vector<bool>::allocator_type.

Member types member type definition notes value_type The first template parameter (bool) allocator_type The second template parameter (Alloc) defaults to: allocator<bool> reference A specific member class (see reference below) const_reference bool pointer a type that simulates pointer behavior convertible to const_pointer const_pointer a type that simulates pointer to const behavior iterator a type that simulates random access iterator behavior convertible to const_iterator const_iterator a type that simulates random access iterator to const behavior reverse_iterator reverse_iterator<iterator> const_reverse_iterator reverse_iterator<const_iterator> difference_type a signed integral type usually the same as ptrdiff_t size_type an unsigned integral type usually the same as size_t
Member classes
vector<bool>::reference
Reference type (public member class)

Member functions The specialization has the same member functions as the unspecialized vector, except data, emplace, and emplace_back, that are not present in this specialization.

It adds the following:


flip
Flip bits (public member function)
swap
Swap containers or elements (public member function)

Non-member class specializations
hash<vector<bool>>
Hash for vector (class template specialization)

Data races Simultaneous access to different elements is not guaranteed to be thread-safe (as storage bytes may be shared by multiple bits).

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4