From Jason Turner

[bitset]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpc78g9szv/{from.md → to.md} +120 -113
tmp/tmpc78g9szv/{from.md → to.md} RENAMED
@@ -5,23 +5,23 @@
5
  The header `<bitset>` defines a class template and several related
6
  functions for representing and manipulating fixed-size sequences of
7
  bits.
8
 
9
  ``` cpp
10
- #include <string>
11
  #include <iosfwd> // for istream[istream.syn], ostream[ostream.syn], see [iosfwd.syn]
12
 
13
  namespace std {
14
  template<size_t N> class bitset;
15
 
16
  // [bitset.operators], bitset operators
17
  template<size_t N>
18
- bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept;
19
  template<size_t N>
20
- bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept;
21
  template<size_t N>
22
- bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept;
23
  template<class charT, class traits, size_t N>
24
  basic_istream<charT, traits>&
25
  operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
26
  template<class charT, class traits, size_t N>
27
  basic_ostream<charT, traits>&
@@ -29,82 +29,85 @@ namespace std {
29
  }
30
  ```
31
 
32
  ### Class template `bitset` <a id="template.bitset">[[template.bitset]]</a>
33
 
 
 
34
  ``` cpp
35
  namespace std {
36
  template<size_t N> class bitset {
37
  public:
38
  // bit reference
39
  class reference {
40
  friend class bitset;
41
- reference() noexcept;
42
 
43
  public:
44
- reference(const reference&) = default;
45
- ~reference();
46
- reference& operator=(bool x) noexcept; // for b[i] = x;
47
- reference& operator=(const reference&) noexcept; // for b[i] = b[j];
48
- bool operator~() const noexcept; // flips the bit
49
- operator bool() const noexcept; // for x = b[i];
50
- reference& flip() noexcept; // for b[i].flip();
51
  };
52
 
53
  // [bitset.cons], constructors
54
  constexpr bitset() noexcept;
55
  constexpr bitset(unsigned long long val) noexcept;
56
  template<class charT, class traits, class Allocator>
57
- explicit bitset(
58
  const basic_string<charT, traits, Allocator>& str,
59
  typename basic_string<charT, traits, Allocator>::size_type pos = 0,
60
  typename basic_string<charT, traits, Allocator>::size_type n
61
  = basic_string<charT, traits, Allocator>::npos,
62
  charT zero = charT('0'),
63
  charT one = charT('1'));
64
  template<class charT>
65
- explicit bitset(
66
  const charT* str,
67
  typename basic_string<charT>::size_type n = basic_string<charT>::npos,
68
  charT zero = charT('0'),
69
  charT one = charT('1'));
70
 
71
  // [bitset.members], bitset operations
72
- bitset<N>& operator&=(const bitset<N>& rhs) noexcept;
73
- bitset<N>& operator|=(const bitset<N>& rhs) noexcept;
74
- bitset<N>& operator^=(const bitset<N>& rhs) noexcept;
75
- bitset<N>& operator<<=(size_t pos) noexcept;
76
- bitset<N>& operator>>=(size_t pos) noexcept;
77
- bitset<N>& set() noexcept;
78
- bitset<N>& set(size_t pos, bool val = true);
79
- bitset<N>& reset() noexcept;
80
- bitset<N>& reset(size_t pos);
81
- bitset<N> operator~() const noexcept;
82
- bitset<N>& flip() noexcept;
83
- bitset<N>& flip(size_t pos);
 
 
84
 
85
  // element access
86
- constexpr bool operator[](size_t pos) const; // for b[i];
87
- reference operator[](size_t pos); // for b[i];
88
 
89
- unsigned long to_ulong() const;
90
- unsigned long long to_ullong() const;
91
  template<class charT = char,
92
  class traits = char_traits<charT>,
93
  class Allocator = allocator<charT>>
94
- basic_string<charT, traits, Allocator>
95
  to_string(charT zero = charT('0'), charT one = charT('1')) const;
96
 
97
- size_t count() const noexcept;
 
98
  constexpr size_t size() const noexcept;
99
- bool operator==(const bitset<N>& rhs) const noexcept;
100
- bool test(size_t pos) const;
101
- bool all() const noexcept;
102
- bool any() const noexcept;
103
- bool none() const noexcept;
104
- bitset<N> operator<<(size_t pos) const noexcept;
105
- bitset<N> operator>>(size_t pos) const noexcept;
106
  };
107
 
108
  // [bitset.hash], hash support
109
  template<class T> struct hash;
110
  template<size_t N> struct hash<bitset<N>>;
@@ -120,11 +123,11 @@ zero. Each bit has a non-negative position `pos`. When converting
120
  between an object of class `bitset<N>` and a value of some integral
121
  type, bit position `pos` corresponds to the *bit value* `1 << pos`. The
122
  integral value corresponding to two or more bits is the sum of their bit
123
  values.
124
 
125
- The functions described in this subclause can report three kinds of
126
  errors, each associated with a distinct exception:
127
 
128
  - an *invalid-argument* error is associated with exceptions of type
129
  `invalid_argument` [[invalid.argument]];
130
  - an *out-of-range* error is associated with exceptions of type
@@ -144,16 +147,17 @@ constexpr bitset() noexcept;
144
  constexpr bitset(unsigned long long val) noexcept;
145
  ```
146
 
147
  *Effects:* Initializes the first `M` bit positions to the corresponding
148
  bit values in `val`. `M` is the smaller of `N` and the number of bits in
149
- the value representation [[basic.types]] of `unsigned long long`. If
150
- `M < N`, the remaining bit positions are initialized to zero.
 
151
 
152
  ``` cpp
153
  template<class charT, class traits, class Allocator>
154
- explicit bitset(
155
  const basic_string<charT, traits, Allocator>& str,
156
  typename basic_string<charT, traits, Allocator>::size_type pos = 0,
157
  typename basic_string<charT, traits, Allocator>::size_type n
158
  = basic_string<charT, traits, Allocator>::npos,
159
  charT zero = charT('0'),
@@ -179,11 +183,11 @@ The function uses `traits::eq` to compare the character values.
179
  any of the `rlen` characters in `str` beginning at position `pos` is
180
  other than `zero` or `one`.
181
 
182
  ``` cpp
183
  template<class charT>
184
- explicit bitset(
185
  const charT* str,
186
  typename basic_string<charT>::size_type n = basic_string<charT>::npos,
187
  charT zero = charT('0'),
188
  charT one = charT('1'));
189
  ```
@@ -198,38 +202,38 @@ bitset(n == basic_string<charT>::npos
198
  ```
199
 
200
  #### Members <a id="bitset.members">[[bitset.members]]</a>
201
 
202
  ``` cpp
203
- bitset<N>& operator&=(const bitset<N>& rhs) noexcept;
204
  ```
205
 
206
  *Effects:* Clears each bit in `*this` for which the corresponding bit in
207
  `rhs` is clear, and leaves all other bits unchanged.
208
 
209
  *Returns:* `*this`.
210
 
211
  ``` cpp
212
- bitset<N>& operator|=(const bitset<N>& rhs) noexcept;
213
  ```
214
 
215
  *Effects:* Sets each bit in `*this` for which the corresponding bit in
216
  `rhs` is set, and leaves all other bits unchanged.
217
 
218
  *Returns:* `*this`.
219
 
220
  ``` cpp
221
- bitset<N>& operator^=(const bitset<N>& rhs) noexcept;
222
  ```
223
 
224
  *Effects:* Toggles each bit in `*this` for which the corresponding bit
225
  in `rhs` is set, and leaves all other bits unchanged.
226
 
227
  *Returns:* `*this`.
228
 
229
  ``` cpp
230
- bitset<N>& operator<<=(size_t pos) noexcept;
231
  ```
232
 
233
  *Effects:* Replaces each bit at position `I` in `*this` with a value
234
  determined as follows:
235
 
@@ -238,11 +242,11 @@ determined as follows:
238
  position `I - pos`.
239
 
240
  *Returns:* `*this`.
241
 
242
  ``` cpp
243
- bitset<N>& operator>>=(size_t pos) noexcept;
244
  ```
245
 
246
  *Effects:* Replaces each bit at position `I` in `*this` with a value
247
  determined as follows:
248
 
@@ -251,19 +255,31 @@ determined as follows:
251
  position `I + pos`.
252
 
253
  *Returns:* `*this`.
254
 
255
  ``` cpp
256
- bitset<N>& set() noexcept;
 
 
 
 
 
 
 
 
 
 
 
 
257
  ```
258
 
259
  *Effects:* Sets all bits in `*this`.
260
 
261
  *Returns:* `*this`.
262
 
263
  ``` cpp
264
- bitset<N>& set(size_t pos, bool val = true);
265
  ```
266
 
267
  *Effects:* Stores a new value in the bit at position `pos` in `*this`.
268
  If `val` is `true`, the stored value is one, otherwise it is zero.
269
 
@@ -271,67 +287,95 @@ If `val` is `true`, the stored value is one, otherwise it is zero.
271
 
272
  *Throws:* `out_of_range` if `pos` does not correspond to a valid bit
273
  position.
274
 
275
  ``` cpp
276
- bitset<N>& reset() noexcept;
277
  ```
278
 
279
  *Effects:* Resets all bits in `*this`.
280
 
281
  *Returns:* `*this`.
282
 
283
  ``` cpp
284
- bitset<N>& reset(size_t pos);
285
  ```
286
 
287
  *Effects:* Resets the bit at position `pos` in `*this`.
288
 
289
  *Returns:* `*this`.
290
 
291
  *Throws:* `out_of_range` if `pos` does not correspond to a valid bit
292
  position.
293
 
294
  ``` cpp
295
- bitset<N> operator~() const noexcept;
296
  ```
297
 
298
- *Effects:* Constructs an object `x` of class `bitset<N>` and initializes
299
- it with `*this`.
300
 
301
  *Returns:* `x.flip()`.
302
 
303
  ``` cpp
304
- bitset<N>& flip() noexcept;
305
  ```
306
 
307
  *Effects:* Toggles all bits in `*this`.
308
 
309
  *Returns:* `*this`.
310
 
311
  ``` cpp
312
- bitset<N>& flip(size_t pos);
313
  ```
314
 
315
  *Effects:* Toggles the bit at position `pos` in `*this`.
316
 
317
  *Returns:* `*this`.
318
 
319
  *Throws:* `out_of_range` if `pos` does not correspond to a valid bit
320
  position.
321
 
322
  ``` cpp
323
- unsigned long to_ulong() const;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  ```
325
 
326
  *Returns:* `x`.
327
 
328
  *Throws:* `overflow_error` if the integral value `x` corresponding to
329
  the bits in `*this` cannot be represented as type `unsigned long`.
330
 
331
  ``` cpp
332
- unsigned long long to_ullong() const;
333
  ```
334
 
335
  *Returns:* `x`.
336
 
337
  *Throws:* `overflow_error` if the integral value `x` corresponding to
@@ -339,11 +383,11 @@ the bits in `*this` cannot be represented as type `unsigned long long`.
339
 
340
  ``` cpp
341
  template<class charT = char,
342
  class traits = char_traits<charT>,
343
  class Allocator = allocator<charT>>
344
- basic_string<charT, traits, Allocator>
345
  to_string(charT zero = charT('0'), charT one = charT('1')) const;
346
  ```
347
 
348
  *Effects:* Constructs a string object of the appropriate type and
349
  initializes it to a string of length `N` characters. Each character is
@@ -354,11 +398,11 @@ Bit value zero becomes the character `zero`, bit value one becomes the
354
  character `one`.
355
 
356
  *Returns:* The created object.
357
 
358
  ``` cpp
359
- size_t count() const noexcept;
360
  ```
361
 
362
  *Returns:* A count of the number of bits set in `*this`.
363
 
364
  ``` cpp
@@ -366,84 +410,44 @@ constexpr size_t size() const noexcept;
366
  ```
367
 
368
  *Returns:* `N`.
369
 
370
  ``` cpp
371
- bool operator==(const bitset<N>& rhs) const noexcept;
372
  ```
373
 
374
  *Returns:* `true` if the value of each bit in `*this` equals the value
375
  of the corresponding bit in `rhs`.
376
 
377
  ``` cpp
378
- bool test(size_t pos) const;
379
  ```
380
 
381
  *Returns:* `true` if the bit at position `pos` in `*this` has the value
382
  one.
383
 
384
  *Throws:* `out_of_range` if `pos` does not correspond to a valid bit
385
  position.
386
 
387
  ``` cpp
388
- bool all() const noexcept;
389
  ```
390
 
391
  *Returns:* `count() == size()`.
392
 
393
  ``` cpp
394
- bool any() const noexcept;
395
  ```
396
 
397
  *Returns:* `count() != 0`.
398
 
399
  ``` cpp
400
- bool none() const noexcept;
401
  ```
402
 
403
  *Returns:* `count() == 0`.
404
 
405
- ``` cpp
406
- bitset<N> operator<<(size_t pos) const noexcept;
407
- ```
408
-
409
- *Returns:* `bitset<N>(*this) <<= pos`.
410
-
411
- ``` cpp
412
- bitset<N> operator>>(size_t pos) const noexcept;
413
- ```
414
-
415
- *Returns:* `bitset<N>(*this) >>= pos`.
416
-
417
- ``` cpp
418
- constexpr bool operator[](size_t pos) const;
419
- ```
420
-
421
- *Preconditions:* `pos` is valid.
422
-
423
- *Returns:* `true` if the bit at position `pos` in `*this` has the value
424
- one, otherwise `false`.
425
-
426
- *Throws:* Nothing.
427
-
428
- ``` cpp
429
- bitset<N>::reference operator[](size_t pos);
430
- ```
431
-
432
- *Preconditions:* `pos` is valid.
433
-
434
- *Returns:* An object of type `bitset<N>::reference` such that
435
- `(*this)[pos] == this->test(pos)`, and such that `(*this)[pos] = val` is
436
- equivalent to `this->set(pos, val)`.
437
-
438
- *Throws:* Nothing.
439
-
440
- *Remarks:* For the purpose of determining the presence of a data
441
- race [[intro.multithread]], any access or update through the resulting
442
- reference potentially accesses or modifies, respectively, the entire
443
- underlying bitset.
444
-
445
  ### `bitset` hash support <a id="bitset.hash">[[bitset.hash]]</a>
446
 
447
  ``` cpp
448
  template<size_t N> struct hash<bitset<N>>;
449
  ```
@@ -451,23 +455,26 @@ template<size_t N> struct hash<bitset<N>>;
451
  The specialization is enabled [[unord.hash]].
452
 
453
  ### `bitset` operators <a id="bitset.operators">[[bitset.operators]]</a>
454
 
455
  ``` cpp
456
- bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs) noexcept;
 
457
  ```
458
 
459
  *Returns:* `bitset<N>(lhs) &= rhs`.
460
 
461
  ``` cpp
462
- bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs) noexcept;
 
463
  ```
464
 
465
  *Returns:* `bitset<N>(lhs) |= rhs`.
466
 
467
  ``` cpp
468
- bitset<N> operator^(const bitset<N>& lhs, const bitset<N>& rhs) noexcept;
 
469
  ```
470
 
471
  *Returns:* `bitset<N>(lhs) ^= rhs`.
472
 
473
  ``` cpp
@@ -487,13 +494,13 @@ the following occurs:
487
  - `N` characters have been extracted and stored;
488
  - end-of-file occurs on the input sequence;
489
  - the next input character is neither `is.widen(’0’)` nor
490
  `is.widen(’1’)` (in which case the input character is not extracted).
491
 
492
- If `N > 0` and no characters are stored in `str`, calls
493
- `is.setstate(ios_base::failbit)` (which may throw `ios_base::failure`
494
- [[iostate.flags]]).
495
 
496
  *Returns:* `is`.
497
 
498
  ``` cpp
499
  template<class charT, class traits, size_t N>
 
5
  The header `<bitset>` defines a class template and several related
6
  functions for representing and manipulating fixed-size sequences of
7
  bits.
8
 
9
  ``` cpp
10
+ #include <string> // see [string.syn]
11
  #include <iosfwd> // for istream[istream.syn], ostream[ostream.syn], see [iosfwd.syn]
12
 
13
  namespace std {
14
  template<size_t N> class bitset;
15
 
16
  // [bitset.operators], bitset operators
17
  template<size_t N>
18
+ constexpr bitset<N> operator&(const bitset<N>&, const bitset<N>&) noexcept;
19
  template<size_t N>
20
+ constexpr bitset<N> operator|(const bitset<N>&, const bitset<N>&) noexcept;
21
  template<size_t N>
22
+ constexpr bitset<N> operator^(const bitset<N>&, const bitset<N>&) noexcept;
23
  template<class charT, class traits, size_t N>
24
  basic_istream<charT, traits>&
25
  operator>>(basic_istream<charT, traits>& is, bitset<N>& x);
26
  template<class charT, class traits, size_t N>
27
  basic_ostream<charT, traits>&
 
29
  }
30
  ```
31
 
32
  ### Class template `bitset` <a id="template.bitset">[[template.bitset]]</a>
33
 
34
+ #### General <a id="template.bitset.general">[[template.bitset.general]]</a>
35
+
36
  ``` cpp
37
  namespace std {
38
  template<size_t N> class bitset {
39
  public:
40
  // bit reference
41
  class reference {
42
  friend class bitset;
43
+ constexpr reference() noexcept;
44
 
45
  public:
46
+ constexpr reference(const reference&) = default;
47
+ constexpr ~reference();
48
+ constexpr reference& operator=(bool x) noexcept; // for b[i] = x;
49
+ constexpr reference& operator=(const reference&) noexcept; // for b[i] = b[j];
50
+ constexpr bool operator~() const noexcept; // flips the bit
51
+ constexpr operator bool() const noexcept; // for x = b[i];
52
+ constexpr reference& flip() noexcept; // for b[i].flip();
53
  };
54
 
55
  // [bitset.cons], constructors
56
  constexpr bitset() noexcept;
57
  constexpr bitset(unsigned long long val) noexcept;
58
  template<class charT, class traits, class Allocator>
59
+ constexpr explicit bitset(
60
  const basic_string<charT, traits, Allocator>& str,
61
  typename basic_string<charT, traits, Allocator>::size_type pos = 0,
62
  typename basic_string<charT, traits, Allocator>::size_type n
63
  = basic_string<charT, traits, Allocator>::npos,
64
  charT zero = charT('0'),
65
  charT one = charT('1'));
66
  template<class charT>
67
+ constexpr explicit bitset(
68
  const charT* str,
69
  typename basic_string<charT>::size_type n = basic_string<charT>::npos,
70
  charT zero = charT('0'),
71
  charT one = charT('1'));
72
 
73
  // [bitset.members], bitset operations
74
+ constexpr bitset& operator&=(const bitset& rhs) noexcept;
75
+ constexpr bitset& operator|=(const bitset& rhs) noexcept;
76
+ constexpr bitset& operator^=(const bitset& rhs) noexcept;
77
+ constexpr bitset& operator<<=(size_t pos) noexcept;
78
+ constexpr bitset& operator>>=(size_t pos) noexcept;
79
+ constexpr bitset operator<<(size_t pos) const noexcept;
80
+ constexpr bitset operator>>(size_t pos) const noexcept;
81
+ constexpr bitset& set() noexcept;
82
+ constexpr bitset& set(size_t pos, bool val = true);
83
+ constexpr bitset& reset() noexcept;
84
+ constexpr bitset& reset(size_t pos);
85
+ constexpr bitset operator~() const noexcept;
86
+ constexpr bitset& flip() noexcept;
87
+ constexpr bitset& flip(size_t pos);
88
 
89
  // element access
90
+ constexpr bool operator[](size_t pos) const;
91
+ constexpr reference operator[](size_t pos);
92
 
93
+ constexpr unsigned long to_ulong() const;
94
+ constexpr unsigned long long to_ullong() const;
95
  template<class charT = char,
96
  class traits = char_traits<charT>,
97
  class Allocator = allocator<charT>>
98
+ constexpr basic_string<charT, traits, Allocator>
99
  to_string(charT zero = charT('0'), charT one = charT('1')) const;
100
 
101
+ // observers
102
+ constexpr size_t count() const noexcept;
103
  constexpr size_t size() const noexcept;
104
+ constexpr bool operator==(const bitset& rhs) const noexcept;
105
+ constexpr bool test(size_t pos) const;
106
+ constexpr bool all() const noexcept;
107
+ constexpr bool any() const noexcept;
108
+ constexpr bool none() const noexcept;
 
 
109
  };
110
 
111
  // [bitset.hash], hash support
112
  template<class T> struct hash;
113
  template<size_t N> struct hash<bitset<N>>;
 
123
  between an object of class `bitset<N>` and a value of some integral
124
  type, bit position `pos` corresponds to the *bit value* `1 << pos`. The
125
  integral value corresponding to two or more bits is the sum of their bit
126
  values.
127
 
128
+ The functions described in [[template.bitset]] can report three kinds of
129
  errors, each associated with a distinct exception:
130
 
131
  - an *invalid-argument* error is associated with exceptions of type
132
  `invalid_argument` [[invalid.argument]];
133
  - an *out-of-range* error is associated with exceptions of type
 
147
  constexpr bitset(unsigned long long val) noexcept;
148
  ```
149
 
150
  *Effects:* Initializes the first `M` bit positions to the corresponding
151
  bit values in `val`. `M` is the smaller of `N` and the number of bits in
152
+ the value representation [[term.object.representation]] of
153
+ `unsigned long long`. If `M < N`, the remaining bit positions are
154
+ initialized to zero.
155
 
156
  ``` cpp
157
  template<class charT, class traits, class Allocator>
158
+ constexpr explicit bitset(
159
  const basic_string<charT, traits, Allocator>& str,
160
  typename basic_string<charT, traits, Allocator>::size_type pos = 0,
161
  typename basic_string<charT, traits, Allocator>::size_type n
162
  = basic_string<charT, traits, Allocator>::npos,
163
  charT zero = charT('0'),
 
183
  any of the `rlen` characters in `str` beginning at position `pos` is
184
  other than `zero` or `one`.
185
 
186
  ``` cpp
187
  template<class charT>
188
+ constexpr explicit bitset(
189
  const charT* str,
190
  typename basic_string<charT>::size_type n = basic_string<charT>::npos,
191
  charT zero = charT('0'),
192
  charT one = charT('1'));
193
  ```
 
202
  ```
203
 
204
  #### Members <a id="bitset.members">[[bitset.members]]</a>
205
 
206
  ``` cpp
207
+ constexpr bitset& operator&=(const bitset& rhs) noexcept;
208
  ```
209
 
210
  *Effects:* Clears each bit in `*this` for which the corresponding bit in
211
  `rhs` is clear, and leaves all other bits unchanged.
212
 
213
  *Returns:* `*this`.
214
 
215
  ``` cpp
216
+ constexpr bitset& operator|=(const bitset& rhs) noexcept;
217
  ```
218
 
219
  *Effects:* Sets each bit in `*this` for which the corresponding bit in
220
  `rhs` is set, and leaves all other bits unchanged.
221
 
222
  *Returns:* `*this`.
223
 
224
  ``` cpp
225
+ constexpr bitset& operator^=(const bitset& rhs) noexcept;
226
  ```
227
 
228
  *Effects:* Toggles each bit in `*this` for which the corresponding bit
229
  in `rhs` is set, and leaves all other bits unchanged.
230
 
231
  *Returns:* `*this`.
232
 
233
  ``` cpp
234
+ constexpr bitset& operator<<=(size_t pos) noexcept;
235
  ```
236
 
237
  *Effects:* Replaces each bit at position `I` in `*this` with a value
238
  determined as follows:
239
 
 
242
  position `I - pos`.
243
 
244
  *Returns:* `*this`.
245
 
246
  ``` cpp
247
+ constexpr bitset& operator>>=(size_t pos) noexcept;
248
  ```
249
 
250
  *Effects:* Replaces each bit at position `I` in `*this` with a value
251
  determined as follows:
252
 
 
255
  position `I + pos`.
256
 
257
  *Returns:* `*this`.
258
 
259
  ``` cpp
260
+ constexpr bitset operator<<(size_t pos) const noexcept;
261
+ ```
262
+
263
+ *Returns:* `bitset(*this) <<= pos`.
264
+
265
+ ``` cpp
266
+ constexpr bitset operator>>(size_t pos) const noexcept;
267
+ ```
268
+
269
+ *Returns:* `bitset(*this) >>= pos`.
270
+
271
+ ``` cpp
272
+ constexpr bitset& set() noexcept;
273
  ```
274
 
275
  *Effects:* Sets all bits in `*this`.
276
 
277
  *Returns:* `*this`.
278
 
279
  ``` cpp
280
+ constexpr bitset& set(size_t pos, bool val = true);
281
  ```
282
 
283
  *Effects:* Stores a new value in the bit at position `pos` in `*this`.
284
  If `val` is `true`, the stored value is one, otherwise it is zero.
285
 
 
287
 
288
  *Throws:* `out_of_range` if `pos` does not correspond to a valid bit
289
  position.
290
 
291
  ``` cpp
292
+ constexpr bitset& reset() noexcept;
293
  ```
294
 
295
  *Effects:* Resets all bits in `*this`.
296
 
297
  *Returns:* `*this`.
298
 
299
  ``` cpp
300
+ constexpr bitset& reset(size_t pos);
301
  ```
302
 
303
  *Effects:* Resets the bit at position `pos` in `*this`.
304
 
305
  *Returns:* `*this`.
306
 
307
  *Throws:* `out_of_range` if `pos` does not correspond to a valid bit
308
  position.
309
 
310
  ``` cpp
311
+ constexpr bitset operator~() const noexcept;
312
  ```
313
 
314
+ *Effects:* Constructs an object `x` of class `bitset` and initializes it
315
+ with `*this`.
316
 
317
  *Returns:* `x.flip()`.
318
 
319
  ``` cpp
320
+ constexpr bitset& flip() noexcept;
321
  ```
322
 
323
  *Effects:* Toggles all bits in `*this`.
324
 
325
  *Returns:* `*this`.
326
 
327
  ``` cpp
328
+ constexpr bitset& flip(size_t pos);
329
  ```
330
 
331
  *Effects:* Toggles the bit at position `pos` in `*this`.
332
 
333
  *Returns:* `*this`.
334
 
335
  *Throws:* `out_of_range` if `pos` does not correspond to a valid bit
336
  position.
337
 
338
  ``` cpp
339
+ constexpr bool operator[](size_t pos) const;
340
+ ```
341
+
342
+ *Preconditions:* `pos` is valid.
343
+
344
+ *Returns:* `true` if the bit at position `pos` in `*this` has the value
345
+ one, otherwise `false`.
346
+
347
+ *Throws:* Nothing.
348
+
349
+ ``` cpp
350
+ constexpr bitset::reference operator[](size_t pos);
351
+ ```
352
+
353
+ *Preconditions:* `pos` is valid.
354
+
355
+ *Returns:* An object of type `bitset::reference` such that
356
+ `(*this)[pos] == this->test(pos)`, and such that `(*this)[pos] = val` is
357
+ equivalent to `this->set(pos, val)`.
358
+
359
+ *Throws:* Nothing.
360
+
361
+ *Remarks:* For the purpose of determining the presence of a data
362
+ race [[intro.multithread]], any access or update through the resulting
363
+ reference potentially accesses or modifies, respectively, the entire
364
+ underlying bitset.
365
+
366
+ ``` cpp
367
+ constexpr unsigned long to_ulong() const;
368
  ```
369
 
370
  *Returns:* `x`.
371
 
372
  *Throws:* `overflow_error` if the integral value `x` corresponding to
373
  the bits in `*this` cannot be represented as type `unsigned long`.
374
 
375
  ``` cpp
376
+ constexpr unsigned long long to_ullong() const;
377
  ```
378
 
379
  *Returns:* `x`.
380
 
381
  *Throws:* `overflow_error` if the integral value `x` corresponding to
 
383
 
384
  ``` cpp
385
  template<class charT = char,
386
  class traits = char_traits<charT>,
387
  class Allocator = allocator<charT>>
388
+ constexpr basic_string<charT, traits, Allocator>
389
  to_string(charT zero = charT('0'), charT one = charT('1')) const;
390
  ```
391
 
392
  *Effects:* Constructs a string object of the appropriate type and
393
  initializes it to a string of length `N` characters. Each character is
 
398
  character `one`.
399
 
400
  *Returns:* The created object.
401
 
402
  ``` cpp
403
+ constexpr size_t count() const noexcept;
404
  ```
405
 
406
  *Returns:* A count of the number of bits set in `*this`.
407
 
408
  ``` cpp
 
410
  ```
411
 
412
  *Returns:* `N`.
413
 
414
  ``` cpp
415
+ constexpr bool operator==(const bitset& rhs) const noexcept;
416
  ```
417
 
418
  *Returns:* `true` if the value of each bit in `*this` equals the value
419
  of the corresponding bit in `rhs`.
420
 
421
  ``` cpp
422
+ constexpr bool test(size_t pos) const;
423
  ```
424
 
425
  *Returns:* `true` if the bit at position `pos` in `*this` has the value
426
  one.
427
 
428
  *Throws:* `out_of_range` if `pos` does not correspond to a valid bit
429
  position.
430
 
431
  ``` cpp
432
+ constexpr bool all() const noexcept;
433
  ```
434
 
435
  *Returns:* `count() == size()`.
436
 
437
  ``` cpp
438
+ constexpr bool any() const noexcept;
439
  ```
440
 
441
  *Returns:* `count() != 0`.
442
 
443
  ``` cpp
444
+ constexpr bool none() const noexcept;
445
  ```
446
 
447
  *Returns:* `count() == 0`.
448
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
449
  ### `bitset` hash support <a id="bitset.hash">[[bitset.hash]]</a>
450
 
451
  ``` cpp
452
  template<size_t N> struct hash<bitset<N>>;
453
  ```
 
455
  The specialization is enabled [[unord.hash]].
456
 
457
  ### `bitset` operators <a id="bitset.operators">[[bitset.operators]]</a>
458
 
459
  ``` cpp
460
+ template<size_t N>
461
+ constexpr bitset<N> operator&(const bitset<N>& lhs, const bitset<N>& rhs) noexcept;
462
  ```
463
 
464
  *Returns:* `bitset<N>(lhs) &= rhs`.
465
 
466
  ``` cpp
467
+ template<size_t N>
468
+ constexpr bitset<N> operator|(const bitset<N>& lhs, const bitset<N>& rhs) noexcept;
469
  ```
470
 
471
  *Returns:* `bitset<N>(lhs) |= rhs`.
472
 
473
  ``` cpp
474
+ template<size_t N>
475
+ constexpr bitset<N> operator^(const bitset<N>& lhs, const bitset<N>& rhs) noexcept;
476
  ```
477
 
478
  *Returns:* `bitset<N>(lhs) ^= rhs`.
479
 
480
  ``` cpp
 
494
  - `N` characters have been extracted and stored;
495
  - end-of-file occurs on the input sequence;
496
  - the next input character is neither `is.widen(’0’)` nor
497
  `is.widen(’1’)` (in which case the input character is not extracted).
498
 
499
+ If `N > 0` and no characters are stored in `str`, `ios_base::failbit` is
500
+ set in the input function’s local error state before `setstate` is
501
+ called.
502
 
503
  *Returns:* `is`.
504
 
505
  ``` cpp
506
  template<class charT, class traits, size_t N>