From Jason Turner

[vector.bool.pspc]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp00u70h9k/{from.md → to.md} +179 -0
tmp/tmp00u70h9k/{from.md → to.md} RENAMED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Partial class template specialization `vector<bool, Allocator>` <a id="vector.bool.pspc">[[vector.bool.pspc]]</a>
2
+
3
+ To optimize space allocation, a partial specialization of `vector` for
4
+ `bool` elements is provided:
5
+
6
+ ``` cpp
7
+ namespace std {
8
+ template<class Allocator>
9
+ class vector<bool, Allocator> {
10
+ public:
11
+ // types
12
+ using value_type = bool;
13
+ using allocator_type = Allocator;
14
+ using pointer = implementation-defined // type of vector<bool>::pointer;
15
+ using const_pointer = implementation-defined // type of vector<bool>::const_pointer;
16
+ using const_reference = bool;
17
+ using size_type = implementation-defined // type of vector<bool>::size_type; // see [container.requirements]
18
+ using difference_type = implementation-defined // type of vector<bool>::difference_type; // see [container.requirements]
19
+ using iterator = implementation-defined // type of vector<bool>::iterator; // see [container.requirements]
20
+ using const_iterator = implementation-defined // type of vector<bool>::const_iterator; // see [container.requirements]
21
+ using reverse_iterator = std::reverse_iterator<iterator>;
22
+ using const_reverse_iterator = std::reverse_iterator<const_iterator>;
23
+
24
+ // bit reference
25
+ class reference {
26
+ friend class vector;
27
+ constexpr reference() noexcept;
28
+
29
+ public:
30
+ constexpr reference(const reference&) = default;
31
+ constexpr ~reference();
32
+ constexpr operator bool() const noexcept;
33
+ constexpr reference& operator=(bool x) noexcept;
34
+ constexpr reference& operator=(const reference& x) noexcept;
35
+ constexpr const reference& operator=(bool x) const noexcept;
36
+ constexpr void flip() noexcept; // flips the bit
37
+ };
38
+
39
+ // construct/copy/destroy
40
+ constexpr vector() noexcept(noexcept(Allocator())) : vector(Allocator()) { }
41
+ constexpr explicit vector(const Allocator&) noexcept;
42
+ constexpr explicit vector(size_type n, const Allocator& = Allocator());
43
+ constexpr vector(size_type n, const bool& value, const Allocator& = Allocator());
44
+ template<class InputIterator>
45
+ constexpr vector(InputIterator first, InputIterator last, const Allocator& = Allocator());
46
+ template<container-compatible-range<bool> R>
47
+ constexpr vector(from_range_t, R&& rg, const Allocator& = Allocator());
48
+ constexpr vector(const vector& x);
49
+ constexpr vector(vector&& x) noexcept;
50
+ constexpr vector(const vector&, const type_identity_t<Allocator>&);
51
+ constexpr vector(vector&&, const type_identity_t<Allocator>&);
52
+ constexpr vector(initializer_list<bool>, const Allocator& = Allocator());
53
+ constexpr ~vector();
54
+ constexpr vector& operator=(const vector& x);
55
+ constexpr vector& operator=(vector&& x)
56
+ noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value ||
57
+ allocator_traits<Allocator>::is_always_equal::value);
58
+ constexpr vector& operator=(initializer_list<bool>);
59
+ template<class InputIterator>
60
+ constexpr void assign(InputIterator first, InputIterator last);
61
+ template<container-compatible-range<bool> R>
62
+ constexpr void assign_range(R&& rg);
63
+ constexpr void assign(size_type n, const bool& t);
64
+ constexpr void assign(initializer_list<bool>);
65
+ constexpr allocator_type get_allocator() const noexcept;
66
+
67
+ // iterators
68
+ constexpr iterator begin() noexcept;
69
+ constexpr const_iterator begin() const noexcept;
70
+ constexpr iterator end() noexcept;
71
+ constexpr const_iterator end() const noexcept;
72
+ constexpr reverse_iterator rbegin() noexcept;
73
+ constexpr const_reverse_iterator rbegin() const noexcept;
74
+ constexpr reverse_iterator rend() noexcept;
75
+ constexpr const_reverse_iterator rend() const noexcept;
76
+
77
+ constexpr const_iterator cbegin() const noexcept;
78
+ constexpr const_iterator cend() const noexcept;
79
+ constexpr const_reverse_iterator crbegin() const noexcept;
80
+ constexpr const_reverse_iterator crend() const noexcept;
81
+
82
+ // capacity
83
+ [[nodiscard]] constexpr bool empty() const noexcept;
84
+ constexpr size_type size() const noexcept;
85
+ constexpr size_type max_size() const noexcept;
86
+ constexpr size_type capacity() const noexcept;
87
+ constexpr void resize(size_type sz, bool c = false);
88
+ constexpr void reserve(size_type n);
89
+ constexpr void shrink_to_fit();
90
+
91
+ // element access
92
+ constexpr reference operator[](size_type n);
93
+ constexpr const_reference operator[](size_type n) const;
94
+ constexpr const_reference at(size_type n) const;
95
+ constexpr reference at(size_type n);
96
+ constexpr reference front();
97
+ constexpr const_reference front() const;
98
+ constexpr reference back();
99
+ constexpr const_reference back() const;
100
+
101
+ // modifiers
102
+ template<class... Args> constexpr reference emplace_back(Args&&... args);
103
+ constexpr void push_back(const bool& x);
104
+ template<container-compatible-range<bool> R>
105
+ constexpr void append_range(R&& rg);
106
+ constexpr void pop_back();
107
+ template<class... Args> constexpr iterator emplace(const_iterator position, Args&&... args);
108
+ constexpr iterator insert(const_iterator position, const bool& x);
109
+ constexpr iterator insert(const_iterator position, size_type n, const bool& x);
110
+ template<class InputIterator>
111
+ constexpr iterator insert(const_iterator position,
112
+ InputIterator first, InputIterator last);
113
+ template<container-compatible-range<bool> R>
114
+ constexpr iterator insert_range(const_iterator position, R&& rg);
115
+ constexpr iterator insert(const_iterator position, initializer_list<bool> il);
116
+
117
+ constexpr iterator erase(const_iterator position);
118
+ constexpr iterator erase(const_iterator first, const_iterator last);
119
+ constexpr void swap(vector&)
120
+ noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
121
+ allocator_traits<Allocator>::is_always_equal::value);
122
+ static constexpr void swap(reference x, reference y) noexcept;
123
+ constexpr void flip() noexcept; // flips all bits
124
+ constexpr void clear() noexcept;
125
+ };
126
+ }
127
+ ```
128
+
129
+ Unless described below, all operations have the same requirements and
130
+ semantics as the primary `vector` template, except that operations
131
+ dealing with the `bool` value type map to bit values in the container
132
+ storage and `allocator_traits::construct` [[allocator.traits.members]]
133
+ is not used to construct these values.
134
+
135
+ There is no requirement that the data be stored as a contiguous
136
+ allocation of `bool` values. A space-optimized representation of bits is
137
+ recommended instead.
138
+
139
+ `reference`
140
+
141
+ is a class that simulates the behavior of references of a single bit in
142
+ `vector<bool>`. The conversion function returns `true` when the bit is
143
+ set, and `false` otherwise. The assignment operators set the bit when
144
+ the argument is (convertible to) `true` and clear it otherwise. `flip`
145
+ reverses the state of the bit.
146
+
147
+ ``` cpp
148
+ constexpr void flip() noexcept;
149
+ ```
150
+
151
+ *Effects:* Replaces each element in the container with its complement.
152
+
153
+ ``` cpp
154
+ static constexpr void swap(reference x, reference y) noexcept;
155
+ ```
156
+
157
+ *Effects:* Exchanges the contents of `x` and `y` as if by:
158
+
159
+ ``` cpp
160
+ bool b = x;
161
+ x = y;
162
+ y = b;
163
+ ```
164
+
165
+ ``` cpp
166
+ template<class Allocator> struct hash<vector<bool, Allocator>>;
167
+ ```
168
+
169
+ The specialization is enabled [[unord.hash]].
170
+
171
+ ``` cpp
172
+ template<class T>
173
+ constexpr bool is-vector-bool-reference = see below;
174
+ ```
175
+
176
+ The expression *`is-vector-bool-reference`*`<T>` is `true` if `T`
177
+ denotes the type `vector<bool, Alloc>::reference` for some type `Alloc`
178
+ and `vector<bool, Alloc>` is not a program-defined specialization.
179
+