]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/dynamic_bitset/dynamic_bitset.html
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / dynamic_bitset / dynamic_bitset.html
CommitLineData
7c673cae
FG
1<?xml version="1.0" encoding="ascii"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
5
6<!--
7 Copyright (c) 2001 Jeremy Siek
8 Copyright (c) 2003-2004, 2008 Gennaro Prota
9 Copyright (c) 2014 Ahmed Charles
10 Copyright (c) 2014 Riccardo Marcangelo
92f5a8d4 11 Copyright (c) 2018 Evgeny Shulgin
7c673cae
FG
12
13 Distributed under the Boost Software License, Version 1.0.
14 (See accompanying file LICENSE_1_0.txt or copy at
15 http://www.boost.org/LICENSE_1_0.txt)
16-->
17
18<!--
19 Copyright (c) 1996-1999
20 Silicon Graphics Computer Systems, Inc.
21
22 Permission to use, copy, modify, distribute and sell this software
23 and its documentation for any purpose is hereby granted without fee,
24 provided that the above copyright notice appears in all copies and
25 that both that copyright notice and this permission notice appear
26 in supporting documentation. Silicon Graphics makes no
27 representations about the suitability of this software for any
28 purpose. It is provided "as is" without express or implied warranty.
29
30 Copyright (c) 1994
31 Hewlett-Packard Company
32
33 Permission to use, copy, modify, distribute and sell this software
34 and its documentation for any purpose is hereby granted without fee,
35 provided that the above copyright notice appears in all copies and
36 that both that copyright notice and this permission notice appear
37 in supporting documentation. Hewlett-Packard Company makes no
38 representations about the suitability of this software for any
39 purpose. It is provided "as is" without express or implied warranty.
40
41 -->
42<head>
43<title>dynamic_bitset&lt;Block, Allocator&gt;</title>
44<link rel="stylesheet" type="text/css" href="../../rst.css" />
45</head>
46
47<body>
48<div id="body">
49<div id="body-inner">
50<div id="content">
51<div class="section" id="docs">
52<div class="section-0">
53<div class="section-body">
54
55<div id="boost-logo"><img src="../../boost.png" alt="Boost C++ Libraries" /></div>
56<h1>dynamic_bitset&lt;Block, Allocator&gt;</h1>
57<h2>Contents</h2>
58
59<dl class="index">
60<dt><a href="#description">Description</a></dt>
61<dt><a href="#synopsis">Synopsis</a></dt>
62<dt><a href="#definitions">Definitions</a></dt>
63<dt><a href="#examples">Examples</a></dt>
64<dt><a href="#rationale">Rationale</a></dt>
65<dt><a href="#header-files">Header Files</a></dt>
66<dt><a href="#template-parameters">Template Parameters</a></dt>
67<dt><a href="#concepts-modeled">Concepts modeled</a></dt>
68
69<dt><a href="#type-requirements">Type requirements</a></dt>
70<dt><a href="#public-base-classes">Public base classes</a></dt>
71<dt><a href="#nested-type-names">Nested type names</a></dt>
72<dt><a href="#public-data-members">Public data members</a></dt>
73<dt><a href="#constructors">Constructors</a></dt>
74<dt><a href="#destructor">Destructor</a></dt>
75<dt><a href="#member-functions">Member functions</a></dt>
76<dt><a href="#non-member-functions">Non-member functions</a></dt>
77<dt><a href="#exception-guarantees">Exception guarantees</a></dt>
78
79<dt><a href="#changes-from-previous-ver"><b>Changes from previous version(s)</b></a></dt>
80<dt><a href="#see-also">See also</a></dt>
81<dt><a href="#acknowledgements">Acknowledgements</a></dt>
82</dl>
83<h3><a id="description">Description</a></h3>
84<p>The <tt>dynamic_bitset</tt> class represents a set of bits. It
85provides accesses to the value of individual bits via an
86<tt>operator[]</tt> and provides all of the bitwise operators
87that one can apply to builtin integers, such as
88<tt>operator&amp;</tt> and <tt>operator&lt;&lt;</tt>. The number
89of bits in the set is specified at runtime via a parameter to the
90constructor of the <tt>dynamic_bitset</tt>.</p>
91
92<p>The <tt>dynamic_bitset</tt> class is nearly identical to the
93<a href=
92f5a8d4 94"https://boost.org/sgi/stl/bitset.html"><tt>std::bitset</tt></a>
7c673cae
FG
95class. The difference is that the size of the
96<tt>dynamic_bitset</tt> (the number of bits) is specified at
97run-time during the construction of a <tt>dynamic_bitset</tt>
98object, whereas the size of a <tt>std::bitset</tt> is specified
99at compile-time through an integer template parameter.</p>
100
101<p>The main problem that <tt>dynamic_bitset</tt> is designed to
102solve is that of representing a subset of a finite set. Each bit
103represents whether an element of the finite set is in the subset
104or not. As such the bitwise operations of
105<tt>dynamic_bitset</tt>, such as <tt>operator&amp;</tt> and
106<tt>operator|</tt>, correspond to set operations, such as
107intersection and union.</p>
108<h3><a id ="synopsis">Synopsis</a></h3>
109<pre>
110namespace boost {
111
112template &lt;typename Block, typename Allocator&gt;
113class dynamic_bitset
114{
115public:
116 typedef Block <a href="#block_type">block_type</a>;
117 typedef Allocator <a href="#allocator_type">allocator_type</a>;
118 typedef <i>implementation-defined</i> <a href="#size_type">size_type</a>;
119
120 static const int <a href=
121 "#bits_per_block">bits_per_block</a> = <i>implementation-defined</i>;
122 static const size_type <a href=
123 "#npos">npos</a> = <i>implementation-defined</i>;
124
125 class <a href="#reference">reference</a>
126 {
127 void operator&amp;(); // not defined
128
129 public:
130 // An automatically generated copy constructor.
131
132 reference&amp; operator=(bool value);
133 reference&amp; operator=(const reference&amp; rhs);
134
135 reference&amp; operator|=(bool value);
136 reference&amp; operator&amp;=(bool value);
137 reference&amp; operator^=(bool value);
138 reference&amp; operator-=(bool value);
139
140 bool operator~() const;
141 operator bool() const;
142 reference&amp; flip();
143 };
144
145 typedef bool <a href="#const_reference">const_reference</a>;
146
92f5a8d4
TL
147 <a href=
148"#cons0">dynamic_bitset</a>();
149
7c673cae 150 explicit <a href=
92f5a8d4 151"#cons1">dynamic_bitset</a>(const Allocator&amp; alloc);
7c673cae
FG
152
153 explicit <a href=
154"#cons2">dynamic_bitset</a>(size_type num_bits, unsigned long value = 0,
155 const Allocator&amp; alloc = Allocator());
156
157 template &lt;typename CharT, typename Traits, typename Alloc&gt;
158 explicit <a href=
159"#cons3">dynamic_bitset</a>(const std::basic_string&lt;CharT, Traits, Alloc&gt;&amp; s,
160 typename std::basic_string&lt;CharT, Traits, Alloc&gt;::size_type pos = 0,
161 typename std::basic_string&lt;CharT, Traits, Alloc&gt;::size_type n = std::basic_string&lt;CharT, Traits, Alloc&gt;::npos,
162 const Allocator&amp; alloc = Allocator());
163
164 template &lt;typename BlockInputIterator&gt;
165 <a href=
166"#cons4">dynamic_bitset</a>(BlockInputIterator first, BlockInputIterator last,
167 const Allocator&amp; alloc = Allocator());
168
169 <a href=
170"#cons5">dynamic_bitset</a>(const dynamic_bitset&amp; b);
171
172 <a href=
173"#move-cons">dynamic_bitset</a>(dynamic_bitset&amp;&amp; b);
174
175 void <a href="#swap">swap</a>(dynamic_bitset&amp; b);
176
177 dynamic_bitset&amp; <a href=
178"#assign">operator=</a>(const dynamic_bitset&amp; b);
179
180 dynamic_bitset&amp; <a href=
181"#move-assign">operator=</a>(dynamic_bitset&amp;&amp; b);
182
183 allocator_type <a href="#get_allocator">get_allocator()</a> const;
184
185 void <a href=
186"#resize">resize</a>(size_type num_bits, bool value = false);
187 void <a href="#clear">clear</a>();
188 void <a href="#pop_back">pop_back</a>();
189 void <a href="#push_back">push_back</a>(bool bit);
190 void <a href="#append1">append</a>(Block block);
191
192 template &lt;typename BlockInputIterator&gt;
193 void <a href="#append2">append</a>(BlockInputIterator first, BlockInputIterator last);
194
195 dynamic_bitset&amp; <a href="#op-and-assign">operator&amp;=</a>(const dynamic_bitset&amp; b);
196 dynamic_bitset&amp; <a href="#op-or-assign">operator|=</a>(const dynamic_bitset&amp; b);
197 dynamic_bitset&amp; <a href="#op-xor-assign">operator^=</a>(const dynamic_bitset&amp; b);
198 dynamic_bitset&amp; <a href="#op-sub-assign">operator-=</a>(const dynamic_bitset&amp; b);
199 dynamic_bitset&amp; <a href="#op-sl-assign">operator&lt;&lt;=</a>(size_type n);
200 dynamic_bitset&amp; <a href="#op-sr-assign">operator&gt;&gt;=</a>(size_type n);
201 dynamic_bitset <a href="#op-sl">operator&lt;&lt;</a>(size_type n) const;
202 dynamic_bitset <a href="#op-sr">operator&gt;&gt;</a>(size_type n) const;
203
92f5a8d4 204 dynamic_bitset&amp; <a href="#set3">set</a>(size_type n, size_type len, bool val);
7c673cae
FG
205 dynamic_bitset&amp; <a href="#set2">set</a>(size_type n, bool val = true);
206 dynamic_bitset&amp; <a href="#set1">set</a>();
92f5a8d4 207 dynamic_bitset&amp; <a href="#reset3">reset</a>(size_type n, size_type len);
7c673cae
FG
208 dynamic_bitset&amp; <a href="#reset2">reset</a>(size_type n);
209 dynamic_bitset&amp; <a href="#reset1">reset</a>();
92f5a8d4 210 dynamic_bitset&amp; <a href="#flip3">flip</a>(size_type n, size_type len);
7c673cae
FG
211 dynamic_bitset&amp; <a href="#flip2">flip</a>(size_type n);
212 dynamic_bitset&amp; <a href="#flip1">flip</a>();
213 bool <a href="#test">test</a>(size_type n) const;
214 bool <a href="#test">test_set</a>(size_type n, bool val = true);
215 bool <a href="#all">all</a>() const;
216 bool <a href="#any">any</a>() const;
217 bool <a href="#none">none</a>() const;
218 dynamic_bitset <a href="#op-not">operator~</a>() const;
219 size_type <a href="#count">count</a>() const noexcept;
220
221 reference <a href="#bracket">operator[]</a>(size_type pos);
222 bool <a href="#const-bracket">operator[]</a>(size_type pos) const;
223
224 unsigned long <a href="#to_ulong">to_ulong</a>() const;
225
226 size_type <a href="#size">size</a>() const noexcept;
227 size_type <a href="#num_blocks">num_blocks</a>() const noexcept;
228 size_type <a href="#max_size">max_size</a>() const noexcept;
229 bool <a href="#empty">empty</a>() const noexcept;
230 size_type <a href="#capacity">capacity</a>() const noexcept;
231 void <a href="#reserve">reserve</a>(size_type num_bits);
232 void <a href="#shrink_to_fit">shrink_to_fit</a>();
233
234 bool <a href="#is_subset_of">is_subset_of</a>(const dynamic_bitset&amp; a) const;
235 bool <a href="#is_proper_subset_of">is_proper_subset_of</a>(const dynamic_bitset&amp; a) const;
236 bool <a href="#intersects">intersects</a>(const dynamic_bitset&amp; a) const;
237
238 size_type <a href="#find_first">find_first</a>() const;
239 size_type <a href="#find_next">find_next</a>(size_type pos) const;
240
241};
242
243
244template &lt;typename B, typename A&gt;
245bool <a href=
246"#op-equal">operator==</a>(const dynamic_bitset&lt;B, A&gt;&amp; a, const dynamic_bitset&lt;B, A&gt;&amp; b);
247
248template &lt;typename Block, typename Allocator&gt;
249bool <a href=
250"#op-not-equal">operator!=</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; a, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b);
251
252template &lt;typename B, typename A&gt;
253bool <a href=
254"#op-less">operator&lt;</a>(const dynamic_bitset&lt;B, A&gt;&amp; a, const dynamic_bitset&lt;B, A&gt;&amp; b);
255
256template &lt;typename Block, typename Allocator&gt;
257bool <a href=
258"#op-less-equal">operator&lt;=</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; a, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b);
259
260template &lt;typename Block, typename Allocator&gt;
261bool <a href=
262"#op-greater">operator&gt;</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; a, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b);
263
264template &lt;typename Block, typename Allocator&gt;
265bool <a href=
266"#op-greater-equal">operator&gt;=</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; a, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b);
267
268template &lt;typename Block, typename Allocator&gt;
269dynamic_bitset&lt;Block, Allocator&gt;
270<a href=
271"#op-and">operator&amp;</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; b1, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b2);
272
273template &lt;typename Block, typename Allocator&gt;
274dynamic_bitset&lt;Block, Allocator&gt;
275<a href=
276"#op-or">operator|</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; b1, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b2);
277
278template &lt;typename Block, typename Allocator&gt;
279dynamic_bitset&lt;Block, Allocator&gt;
280<a href=
281"#op-xor">operator^</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; b1, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b2);
282
283template &lt;typename Block, typename Allocator&gt;
284dynamic_bitset&lt;Block, Allocator&gt;
285<a href=
286"#op-sub">operator-</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; b1, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b2);
287
288template &lt;typename Block, typename Allocator, typename CharT, typename Alloc&gt;
289void <a href=
290"#to_string">to_string</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; b,
291 std::basic_string&lt;CharT, Alloc&gt;&amp; s);
292
293template &lt;typename Block, typename Allocator, typename BlockOutputIterator&gt;
294void <a href=
295"#to_block_range">to_block_range</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; b,
296 BlockOutputIterator result);
297
298template &lt;typename CharT, typename Traits, typename Block, typename Allocator&gt;
299std::basic_ostream&lt;CharT, Traits&gt;&amp;
300<a href=
301"#op-out">operator&lt;&lt;</a>(std::basic_ostream&lt;CharT, Traits&gt;&amp; os, const dynamic_bitset&lt;Block, Allocator&gt;&amp; b);
302
303template &lt;typename CharT, typename Traits, typename Block, typename Allocator&gt;
304std::basic_istream&lt;CharT, Traits&gt;&amp;
305<a href=
306"#op-in">operator&gt;&gt;</a>(std::basic_istream&lt;CharT, Traits&gt;&amp; is, dynamic_bitset&lt;Block, Allocator&gt;&amp; b);
307
308} // namespace boost
309</pre>
310
311<h3><a id="definitions">Definitions</a></h3>
312
313<p>Each bit represents either the Boolean value true or false (1
314or 0). To <i>set</i> a bit is to assign it 1. To <i>clear</i> or
315<i>reset</i> a bit is to assign it 0. To <i>flip</i> a bit is to
316change the value to 1 if it was 0 and to 0 if it was 1. Each bit
317has a non-negative <i>position</i>. A bitset <tt>x</tt> contains
318<tt>x.size()</tt> bits, with each bit assigned a unique position
319in the range <tt>[0,x.size())</tt>. The bit at position 0 is
320called the <i>least significant bit</i> and the bit at position
321<tt>size() - 1</tt> is the <i>most significant bit</i>. When
322converting an instance of <tt>dynamic_bitset</tt> to or from an
323unsigned long <tt>n</tt>, the bit at position <tt>i</tt> of the
324bitset has the same value as <tt>(n &gt;&gt; i) &amp; 1</tt>.</p>
325
326<h3><a id="examples">Examples</a></h3>
327
328<p>
329<a href="./example/example1.cpp">Example 1</a> (setting
330and reading some bits)
331</p>
332<p>
333<a href="./example/example2.cpp">Example 2</a> (creating
334some bitsets from integers)
335</p>
336
337<p>
338<a href="./example/example3.cpp">Example 3</a> (performing
339input/output and some bitwise operations).
340</p>
341
342
343<h3><a id="rationale">Rationale</a></h3>
344<p>
345<tt>dynamic_bitset</tt> is not a <a href=
92f5a8d4 346"https://boost.org/sgi/stl/Container.html">Container</a> and
7c673cae
FG
347does not provide iterators for the following reason:
348</p>
349
350<ul>
351<li>A container with a proxy <tt>reference</tt> type can not
352fulfill the container requirements as specified in the C++
353standard (unless one resorts to strange iterator semantics).
354<tt>std::vector&lt;bool&gt;</tt> has a proxy <tt>reference</tt>
355type and does not fulfill the container requirements and as a
356result has caused many problems. One common problem is when
357people try to use iterators from <tt>std::vector&lt;bool&gt;</tt>
358with a Standard algorithm such as <tt>std::search</tt>. The
359<tt>std::search</tt> requirements say that the iterator must be a
360<a href=
92f5a8d4 361"https://boost.org/sgi/stl/ForwardIterator.html">Forward
7c673cae
FG
362Iterator</a>, but the <tt>std::vector&lt;bool&gt;::iterator</tt>
363does not meet this requirement because of the proxy reference.
364Depending on the implementation, they may or not be a compile
365error or even a run-time error due to this misuse. For further
366discussion of the problem see <i>Effective STL</i> by Scott
367Meyers). So <tt>dynamic_bitset</tt> tries to avoid these problems
368by not pretending to be a container.</li>
369</ul>
370
371<p>Some people prefer the name "toggle" to "flip". The name
372"flip" was chosen because that is the name used in <a href=
92f5a8d4 373"https://boost.org/sgi/stl/bitset.html"><tt>std::bitset</tt></a>.
7c673cae
FG
374In fact, most of the function names for <tt>dynamic_bitset</tt>
375were chosen for this reason.</p>
376
377<p><tt>dynamic_bitset</tt> does not throw exceptions when a
378precondition is violated (as is done in <tt>std::bitset</tt>).
379Instead <tt>assert</tt> is used. See the guidelines for <a href=
380"http://www.boost.org/community/error_handling.html">Error and Exception Handling</a>
381for the explanation.</p>
382
383<h3><a id="header-files">Header Files</a></h3>
384
385<p>The class <tt>dynamic_bitset</tt> is defined in the header <a
386href=
387"../../boost/dynamic_bitset.hpp">boost/dynamic_bitset.hpp</a>.
388Also, there is a forward declaration for <tt>dynamic_bitset</tt>
389in the header <a href=
390"../../boost/dynamic_bitset_fwd.hpp">boost/dynamic_bitset_fwd.hpp</a>.</p>
391
392<h3><a id="template-parameters">Template parameters</a></h3>
393
394<table summary=
395"Describes the meaning of the template parameters and lists their corresponding default arguments">
396<tr>
397<th>Parameter</th>
398<th>Description</th>
399<th>Default</th>
400</tr>
401<tr>
402<td><tt>Block</tt></td>
403<td>The integer type in which the bits are stored.</td>
404<td><tt>unsigned long</tt></td>
405</tr>
406<tr>
407
408<td><tt>Allocator</tt></td>
409<td>The allocator type used for all internal memory management.</td>
410<td><tt>std::allocator&lt;Block&gt;</tt></td>
411</tr>
412</table>
413<h3><a id="concepts-modeled">Concepts Modeled</a></h3>
414<a href=
92f5a8d4 415"https://boost.org/sgi/stl/Assignable.html">Assignable</a>, <a
7c673cae 416href=
92f5a8d4 417"https://boost.org/sgi/stl/DefaultConstructible.html">Default
7c673cae 418Constructible</a>, <a href=
92f5a8d4 419"https://boost.org/sgi/stl/EqualityComparable.html">Equality
7c673cae 420Comparable</a>, <a href=
92f5a8d4 421"https://boost.org/sgi/stl/LessThanComparable.html">LessThan
7c673cae
FG
422Comparable</a>.
423
424<h3><a id="type-requirements">Type requirements</a></h3>
425
426<tt>Block</tt> is an unsigned integer type. <tt>Allocator</tt>
427satisfies the Standard requirements for an allocator.
428
429<h3><a id="public-base-classes">Public base classes</a></h3>
430
431None.
432<h3><a id="nested-type-names">Nested type names</a></h3>
433<hr />
434
435<pre>
436<a id="reference">dynamic_bitset::reference</a>
437</pre>
438
439<p>A proxy class that acts as a reference to a single bit. It
440contains an assignment operator, a conversion to <tt>bool</tt>,
441an <tt>operator~</tt>, and a member function <tt>flip</tt>. It
442exists only as a helper class for <tt>dynamic_bitset</tt>'s
443<tt>operator[]</tt>. The following table describes the valid
444operations on the <tt>reference</tt> type. Assume that <tt>b</tt>
445is an instance of <tt>dynamic_bitset</tt>, <tt>i, j</tt> are of
446<tt>size_type</tt> and in the range <tt>[0,b.size())</tt>. Also,
447note that when we write <tt>b[i]</tt> we mean an object of type
448<tt>reference</tt> that was initialized from <tt>b[i]</tt>. The
449variable <tt>x</tt> is a <tt>bool</tt>.</p>
450
451<table border="1" summary=
452"Semantics of several expressions involving usage of dynamic_bitset::reference">
453<tr>
454<th>Expression</th>
455<th>Semantics</th>
456</tr>
457<tr>
458<td><tt>x = b[i]</tt></td>
459<td>Assign the ith bit of <tt>b</tt> to <tt>x</tt>.</td>
460</tr>
461<tr>
462<td><tt>(bool)b[i]</tt></td>
463<td>Return the ith bit of <tt>b</tt>.</td>
464</tr>
465<tr>
466<td><tt>b[i] = x</tt></td>
467<td>Set the ith bit of <tt>b</tt> to the value of <tt>x</tt> and
468return <tt>b[i]</tt>.</td>
469</tr>
470<tr>
471<td><tt>b[i] |= x</tt></td>
472<td>Or the ith bit of <tt>b</tt> with the value of <tt>x</tt> and
473return <tt>b[i]</tt>.</td>
474</tr>
475<tr>
476<td><tt>b[i] &amp;= x</tt></td>
477<td>And the ith bit of <tt>b</tt> with the value of <tt>x</tt>
478and return <tt>b[i]</tt>.</td>
479</tr>
480
481<tr>
482<td><tt>b[i] ^= x</tt></td>
483<td>Exclusive-Or the ith bit of <tt>b</tt> with the value of
484<tt>x</tt> and return <tt>b[i]</tt>.</td>
485</tr>
486
487<tr>
488<td><tt>b[i] -= x</tt></td>
489<td>If <tt>x==true</tt>, clear the ith bit of <tt>b</tt>. Returns
490<tt>b[i]</tt>.</td>
491</tr>
492
493<tr>
494<td><tt>b[i] = b[j]</tt></td>
495<td>Set the ith bit of <tt>b</tt> to the value of the jth bit of
496<tt>b</tt> and return <tt>b[i]</tt>.</td>
497</tr>
498
499<tr>
500<td><tt>b[i] |= b[j]</tt></td>
501<td>Or the ith bit of <tt>b</tt> with the jth bit of <tt>b</tt>
502and return <tt>b[i]</tt>.</td>
503</tr>
504
505<tr>
506<td><tt>b[i] &amp;= b[j]</tt></td>
507<td>And the ith bit of <tt>b</tt> with the jth bit of <tt>b</tt> and return <tt>b[i]</tt>.</td>
508</tr>
509<tr>
510<td><tt>b[i] ^= b[j]</tt></td>
511<td>Exclusive-Or the ith bit of <tt>b</tt> with the jth bit of <tt>b</tt> and return <tt>b[i]</tt>.</td>
512
513</tr>
514<tr>
515<td><tt>b[i] -= b[j]</tt></td>
516<td>If the jth bit of <tt>b</tt> is set, clear the ith bit of <tt>b</tt>. Returns <tt>b[i]</tt>.</td>
517</tr>
518<tr>
519<td><tt>x = ~b[i]</tt></td>
520
521<td>Assign the opposite of the ith bit of <tt>b</tt> to <tt>x</tt>.</td>
522</tr>
523<tr>
524<td><tt>(bool)~b[i]</tt></td>
525<td>Return the opposite of the ith bit of <tt>b</tt>.</td>
526</tr>
527<tr>
528
529<td><tt>b[i].flip()</tt></td>
530<td>Flip the ith bit of <tt>b</tt> and return <tt>b[i]</tt>.</td>
531</tr>
532</table>
533<hr />
534<pre>
535<a id="const_reference">dynamic_bitset::const_reference</a>
536</pre>
537The type <tt>bool</tt>.
538
539<pre>
540<a id="size_type">dynamic_bitset::size_type</a>
541</pre>
542The unsigned integer type for representing the size of the bit set.
543
544<pre>
545<a id="block_type">dynamic_bitset::block_type</a>
546</pre>
547The same type as <tt>Block</tt>.
548
549<pre>
550<a id="allocator_type">dynamic_bitset::allocator_type;</a>
551</pre>
552The same type as <tt>Allocator</tt>.
553
554
555<hr />
556<h3><a id="public-data-members">Public data members</a></h3>
557
558<pre>
559<a id="bits_per_block">dynamic_bitset::bits_per_block</a>
560</pre>
561The number of bits the type <tt>Block</tt> uses to represent values,
562excluding any padding bits. Numerically equal
563to <tt>std::numeric_limits&lt;Block&gt;::digits</tt>.
564
565<pre>
566<a id="npos">dynamic_bitset::npos</a>
567</pre>
568The maximum value of <tt>size_type</tt>.
569
570<hr />
571<h3><a id="constructors">Constructors</a></h3>
572
573<hr />
574<pre>
575<a id=
92f5a8d4
TL
576"cons0">dynamic_bitset</a>()
577</pre>
578
579<b>Effects:</b> Constructs a bitset of size zero. The allocator
580for this bitset is a default-constructed object of type
581<tt>Allocator</tt>.<br />
582 <b>Postconditions:</b> <tt>this-&gt;size() == 0</tt>.<br />
583 <b>Throws:</b> Nothing unless the default constructor of
584<tt>Allocator</tt> throws an exception.<br />
585 (Required by <a href=
586"https://boost.org/sgi/stl/DefaultConstructible.html">Default
587Constructible</a>.)
588
589<hr />
590<pre>
591<a id=
592"cons1">dynamic_bitset</a>(const Allocator&amp; alloc)
7c673cae
FG
593</pre>
594
595<b>Effects:</b> Constructs a bitset of size zero. A copy of the
596<tt>alloc</tt> object will be used in subsequent bitset
597operations such as <tt>resize</tt> to allocate memory.<br />
598 <b>Postconditions:</b> <tt>this-&gt;size() == 0</tt>.<br />
92f5a8d4 599 <b>Throws:</b> nothing.
7c673cae
FG
600
601<hr />
602<pre>
603<a id="cons2">dynamic_bitset</a>(size_type num_bits,
604 unsigned long value = 0,
605 const Allocator&amp; alloc = Allocator())
606</pre>
607
608<b>Effects:</b> Constructs a bitset from an integer. The first
609<tt>M</tt> bits are initialized to the corresponding bits in
610<tt>value</tt> and all other bits, if any, to zero (where <tt>M =
611min(num_bits, std::numeric_limits&lt;unsigned long&gt;::digits)</tt>). A copy of
612the <tt>alloc</tt> object will be used in subsequent bitset
613operations such as <tt>resize</tt> to allocate memory. Note that, e.g., the
614following
615<br /><br />
616<tt>
617dynamic_bitset b<>( 16, 7 );
618</tt><br /><br />
619will match the <a href="#cons4">constructor from an iterator range</a> (not this
620one), but the underlying implementation will still "do the right thing" and
621construct a bitset of 16 bits, from the value 7.
622<br />
623<b>Postconditions:</b>
624
625<ul>
626<li><tt>this-&gt;size() == num_bits</tt></li>
627
628<li>For all <tt>i</tt> in the range <tt>[0,M)</tt>,
629<tt>(*this)[i] == (value &gt;&gt; i) &amp; 1</tt>.</li>
630
631<li>For all <tt>i</tt> in the range <tt>[M,num_bits)</tt>,
632<tt>(*this)[i] == false</tt>.</li>
633</ul>
634
635<b>Throws:</b> An allocation error if memory is exhausted
636(<tt>std::bad_alloc</tt> if
637<tt>Allocator=std::allocator</tt>).<br />
638
639
640<hr />
641<pre>
642<a id="cons5">dynamic_bitset</a>(const dynamic_bitset&amp; x)
643</pre>
644
645<b>Effects:</b> Constructs a bitset that is a copy of the bitset
646<tt>x</tt>. The allocator for this bitset is a copy of the
647allocator in <tt>x</tt>. <br />
648 <b>Postconditions:</b> For all <tt>i</tt> in the range
649<tt>[0,x.size())</tt>, <tt>(*this)[i] == x[i]</tt>.<br />
650 <b>Throws:</b> An allocation error if memory is exhausted
651(<tt>std::bad_alloc</tt> if
652<tt>Allocator=std::allocator</tt>).<br />
653 (Required by <a href=
92f5a8d4 654"https://boost.org/sgi/stl/Assignable.html">Assignable</a>.)
7c673cae
FG
655
656<hr />
657<pre>
658<a id="move-cons">dynamic_bitset</a>(dynamic_bitset&amp;&amp; x)
659</pre>
660
661<b>Effects:</b> Constructs a bitset that is the same as the bitset
662<tt>x</tt>, while using the resources from <tt>x</tt>. The allocator
663for this bitset is moved from the allocator in <tt>x</tt>. <br />
664 <b>Postconditions:</b> For all <tt>i</tt> in the range
665<tt>[0,x.size())</tt>, <tt>(*this)[i] == x[i]</tt>.<br />
666 <b>Throws:</b> An allocation error if memory is exhausted
667(<tt>std::bad_alloc</tt> if
668<tt>Allocator=std::allocator</tt>).
669
670<hr />
671<pre>
672template &lt;typename BlockInputIterator&gt;
673explicit
674<a id=
675"cons4">dynamic_bitset</a>(BlockInputIterator first, BlockInputIterator last,
676 const Allocator&amp; alloc = Allocator());
677</pre>
678
679<b>Effects:</b>
680<ul>
681<li>
682If this constructor is called with a type <tt>BlockInputIterator</tt> which
683<i>is actually an integral type</i>, the library behaves as if the constructor
684from <tt>unsigned long</tt> were called, with arguments
685<tt>static_cast&lt;size_type&gt;(first), last and alloc</tt>, in that order.
686<br /><br />
687Example:
688<pre>
689// b is constructed as if by calling the constructor
690//
691// dynamic_bitset(size_type num_bits,
692// unsigned long value = 0,
693// const Allocator&amp; alloc = Allocator())
694//
695// with arguments
696//
697// static_cast&lt;dynamic_bitset&lt;unsigned short&gt;::size_type&gt;(8),
698// 7,
699// Allocator()
700//
701dynamic_bitset&lt;unsigned short&gt; b(8, 7);
702</pre><br />
703<i>Note:</i><br/>
704At the time of writing (October 2008) this is aligned with the
705proposed resolution for <a href=
706 "http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#438">library
707 issue 438</a>. That is a <em>post <tt>C++03</tt></em>
708change, and is currently in the working paper for
709<tt>C++0x</tt>. Informally speaking, the critical changes with
710respect to <tt>C++03</tt> are the drop of a <tt>static_cast</tt>
711on the second argument, and more leeway as to <em>when</em> the
712templated constructor should have the same effect as the (size,
713value) one: only when <tt>InputIterator</tt> is an integral
714type, in <tt>C++03</tt>; when it is either an integral type or
715any other type that the implementation might detect as
716impossible to be an input iterator, with the proposed
717resolution. For the purposes of <tt>dynamic_bitset</tt> we limit
718ourselves to the first of these two changes.<br /><br />
719</li>
720<li>
721<i>Otherwise</i> (<i>i.e.</i> if the template argument is not an
722integral type), constructs&mdash;under the condition in the
723<tt>requires</tt> clause&mdash;a bitset based on a range of
724blocks. Let <tt>*first</tt> be block number 0, <tt>*++first</tt>
725block number 1, etc. Block number <tt>b</tt> is used to
726initialize the bits of the dynamic_bitset in the position range
727<tt>[b*bits_per_block, (b+1)*bits_per_block)</tt>. For each
728block number <tt>b</tt> with value <tt>bval</tt>, the bit
729<tt>(bval &gt;&gt; i) &amp; 1</tt> corresponds to the bit at
730position <tt>(b * bits_per_block + i)</tt> in the bitset (where
731<tt>i</tt> goes through the range <tt>[0, bits_per_block)</tt>).
732</li>
733</ul>
734<br />
735<b>Requires:</b> <tt>BlockInputIterator</tt> must be either an
736integral type or a model of <a href=
92f5a8d4 737 "https://boost.org/sgi/stl/InputIterator.html">Input
7c673cae
FG
738 Iterator</a> whose <tt>value_type</tt> is the same type as
739<tt>Block</tt>.<br /> <b>Throws:</b> An allocation error if
740memory is exhausted (<tt>std::bad_alloc</tt> if
741<tt>Allocator=std::allocator</tt>).<br />
742
743<hr />
744<pre>
745template&lt;typename Char, typename Traits, typename Alloc&gt;
746explicit
747<a id="cons3">dynamic_bitset</a>(const <a href=
92f5a8d4 748"https://boost.org/sgi/stl/basic_string.html">std::basic_string</a>&lt;Char,Traits,Alloc&gt;&amp; s,
7c673cae
FG
749 typename std::basic_string&lt;CharT, Traits, Alloc&gt;::size_type pos = 0,
750 typename std::basic_string&lt;CharT, Traits, Alloc&gt;::size_type n = <a
751 href=
92f5a8d4 752"https://boost.org/sgi/stl/basic_string.html">std::basic_string</a>&lt;Char,Traits,Alloc&gt;::npos,
7c673cae
FG
753 const Allocator&amp; alloc = Allocator())
754</pre>
755
756<b>Precondition:</b> <tt>pos &lt;= s.size()</tt> and the
757characters used to initialize the bits must be <tt>0</tt> or
758<tt>1</tt>.<br />
759 <b>Effects:</b> Constructs a bitset from a string of 0's and
7601's. The first <tt>M</tt> bits are initialized to the
761corresponding characters in <tt>s</tt>, where <tt>M =
762min(s.size() - pos, n)</tt>. Note that the <i>highest</i>
763character position in <tt>s</tt>, not the lowest, corresponds to
764the least significant bit. That is, character position <tt>pos +
765M - 1 - i</tt> corresponds to bit <tt>i</tt>. So, for example,
766<tt>dynamic_bitset(string("1101"))</tt> is the same as
767<tt>dynamic_bitset(13ul)</tt>.<br />
768 <b>Throws:</b> an allocation error if memory is exhausted
769(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
770
771<hr />
772<h3><a id="destructor">Destructor</a></h3>
773
774<hr />
775<pre>
776~dynamic_bitset()
777</pre>
778
779<b>Effects:</b> Releases the memory associated with this bitset
780and destroys the bitset object itself.<br />
781 <b>Throws:</b> nothing.
782
783<hr />
784<h3><a id="member-functions">Member Functions</a></h3>
785
786<hr />
787<pre>
788void <a id="swap">swap</a>(dynamic_bitset&amp; b);
789</pre>
790
791<b>Effects:</b> The contents of this bitset and bitset <tt>b</tt>
792are exchanged.<br />
793<b>Postconditions:</b> This bitset is equal to the original
794<tt>b</tt>, and <tt>b</tt> is equal to the previous version of
795this bitset.<br />
796<b>Throws:</b> nothing.
797
798<hr />
799<pre>
800dynamic_bitset&amp; <a id=
801"assign">operator=</a>(const dynamic_bitset&amp; x)
802</pre>
803
804<b>Effects:</b> This bitset becomes a copy of the bitset
805<tt>x</tt>.<br />
806 <b>Postconditions:</b> For all <tt>i</tt> in the range
807<tt>[0,x.size())</tt>, <tt>(*this)[i] == x[i]</tt>.<br />
808 <b>Returns:</b> <tt>*this</tt>.<br />
809 <b>Throws:</b> nothing. <br />
810(Required by <a href=
92f5a8d4 811"https://boost.org/sgi/stl/Assignable.html">Assignable</a>.)
7c673cae
FG
812
813<hr />
814<pre>
815dynamic_bitset&amp; <a id=
816"move-assign">operator=</a>(dynamic_bitset&amp;&amp; x)
817</pre>
818
819<b>Effects:</b> This bitset becomes the same as the bitset
820<tt>x</tt>, while using the resources from <tt>x</tt>.<br />
821 <b>Postconditions:</b> For all <tt>i</tt> in the range
822<tt>[0,x.size())</tt>, <tt>(*this)[i] == x[i]</tt>.<br />
823 <b>Returns:</b> <tt>*this</tt>.<br />
824 <b>Throws:</b> An allocation error if memory is exhausted
825(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
826
827<hr />
828<pre>
829allocator_type <a id="get_allocator">get_allocator()</a> const;
830</pre>
831 <b>Returns:</b> A copy of the allocator object used to construct <tt>*this</tt>.
832
833<hr />
834<pre>
835void <a id=
836"resize">resize</a>(size_type num_bits, bool value = false);
837</pre>
838
839<b>Effects:</b> Changes the number of bits of the bitset to
840<tt>num_bits</tt>. If <tt>num_bits &gt; size()</tt> then the bits
841in the range <tt>[0,size())</tt> remain the same, and the bits in
842<tt>[size(),num_bits)</tt> are all set to <tt>value</tt>. If
843<tt>num_bits &lt; size()</tt> then the bits in the range
844<tt>[0,num_bits)</tt> stay the same (and the remaining bits are
845discarded).<br />
846 <b>Postconditions:</b> <tt>this-&gt;size() == num_bits</tt>.<br />
847 <b>Throws:</b> An allocation error if memory is exhausted
848(<tt>std::bad_alloc</tt> if
849<tt>Allocator=std::allocator</tt>).<br />
850
851
852<hr />
853<pre>
854void <a id="clear">clear</a>()
855</pre>
856
857<b>Effects:</b> The size of the bitset becomes zero.<br />
858 <b>Throws:</b> nothing.
859
860<hr />
861<pre>
862void <a id="pop_back">pop_back</a>();
863</pre>
864
865<b>Precondition:</b> <tt>!this-&gt;empty()</tt>.<br />
866<b>Effects:</b> Decreases the size of the bitset by one.<br />
867 <b>Throws:</b> nothing.
868
869<hr />
870<pre>
871void <a id="push_back">push_back</a>(bool value);
872</pre>
873
874<b>Effects:</b> Increases the size of the bitset by one, and sets
875the value of the new most-significant bit to <tt>value</tt>.<br />
876 <b>Throws:</b> An allocation error if memory is exhausted
877(<tt>std::bad_alloc</tt> if
878<tt>Allocator=std::allocator</tt>).<br />
879
880
881<hr />
882<pre>
883void <a id="append1">append</a>(Block value);
884</pre>
885
886<b>Effects:</b> Appends the bits in <tt>value</tt> to the bitset
887(appends to the most-significant end). This increases the size of
888the bitset by <tt>bits_per_block</tt>. Let <tt>s</tt> be the old
889size of the bitset, then for <tt>i</tt> in the range
890<tt>[0,bits_per_block)</tt>, the bit at position <tt>(s + i)</tt>
891is set to <tt>((value &gt;&gt; i) &amp; 1)</tt>.<br />
892 <b>Throws:</b> An allocation error if memory is exhausted
893(<tt>std::bad_alloc</tt> if
894<tt>Allocator=std::allocator</tt>).<br />
895
896
897<hr />
898<pre>
899template &lt;typename BlockInputIterator&gt;
900void <a id=
901"append2">append</a>(BlockInputIterator first, BlockInputIterator last);
902</pre>
903
904<b>Effects:</b> This function provides the same end result as the
905following code, but is typically more efficient.
906
907<pre>
908for (; first != last; ++first)
909 append(*first);
910</pre>
911
912<b>Requires:</b> The <tt>BlockInputIterator</tt> type must be a
913model of <a href=
92f5a8d4 914"https://boost.org/sgi/stl/InputIterator.html">Input
7c673cae
FG
915Iterator</a> and the <tt>value_type</tt> must be the same type as
916<tt>Block</tt>.<br />
917 <b>Throws:</b> An allocation error if memory is exhausted
918(<tt>std::bad_alloc</tt> if
919<tt>Allocator=std::allocator</tt>).<br />
920
921
922<hr />
923<pre>
924dynamic_bitset&amp; <a id=
925"op-and-assign">operator&amp;=</a>(const dynamic_bitset&amp; rhs)
926</pre>
927
928<b>Requires:</b> <tt>this-&gt;size() == rhs.size()</tt>.<br />
929 <b>Effects:</b> Bitwise-AND all the bits in <tt>rhs</tt> with
930the bits in this bitset. This is equivalent to:
931
932<pre>
933for (size_type i = 0; i != this-&gt;size(); ++i)
934 (*this)[i] = (*this)[i] &amp; rhs[i];
935</pre>
936
937<b>Returns:</b> <tt>*this</tt>.<br />
938 <b>Throws:</b> nothing.
939
940<hr />
941<pre>
942dynamic_bitset&amp; <a id=
943"op-or-assign">operator|=</a>(const dynamic_bitset&amp; rhs)
944</pre>
945
946<b>Requires:</b> <tt>this-&gt;size() == rhs.size()</tt>.<br />
947 <b>Effects:</b> Bitwise-OR's all the bits in <tt>rhs</tt> with
948the bits in this bitset. This is equivalent to:
949
950<pre>
951for (size_type i = 0; i != this-&gt;size(); ++i)
952 (*this)[i] = (*this)[i] | rhs[i];
953</pre>
954
955<b>Returns:</b> <tt>*this</tt>.<br />
956 <b>Throws:</b> nothing.
957
958<hr />
959<pre>
960dynamic_bitset&amp; <a id=
961"op-xor-assign">operator^=</a>(const dynamic_bitset&amp; rhs)
962</pre>
963
964<b>Requires:</b> <tt>this-&gt;size() == rhs.size()</tt>.<br />
965 <b>Effects:</b> Bitwise-XOR's all the bits in <tt>rhs</tt> with
966the bits in this bitset. This is equivalent to:
967
968<pre>
969for (size_type i = 0; i != this-&gt;size(); ++i)
970 (*this)[i] = (*this)[i] ^ rhs[i];
971</pre>
972
973<b>Returns:</b> <tt>*this</tt>.<br />
974 <b>Throws:</b> nothing.
975
976<hr />
977<pre>
978dynamic_bitset&amp; <a id=
979"op-sub-assign">operator-=</a>(const dynamic_bitset&amp; rhs)
980</pre>
981
982<b>Requires:</b> <tt>this-&gt;size() == rhs.size()</tt>.<br />
983 <b>Effects:</b> Computes the set difference of this bitset and
984the <tt>rhs</tt> bitset. This is equivalent to:
985
986<pre>
987for (size_type i = 0; i != this-&gt;size(); ++i)
988 (*this)[i] = (*this)[i] &amp;&amp; !rhs[i];
989</pre>
990
991<b>Returns:</b> <tt>*this</tt>.<br />
992 <b>Throws:</b> nothing.
993
994<hr />
995<pre>
996dynamic_bitset&amp; <a id=
997"op-sl-assign">operator&lt;&lt;=</a>(size_type n)
998</pre>
999
1000<b>Effects:</b> Shifts the bits in this bitset to the left by
1001<tt>n</tt> bits. For each bit in the bitset, the bit at position
1002pos takes on the previous value of the bit at position <tt>pos -
1003n</tt>, or zero if no such bit exists.<br />
1004 <b>Returns:</b> <tt>*this</tt>.<br />
1005 <b>Throws:</b> nothing.
1006
1007<hr />
1008<pre>
1009dynamic_bitset&amp; <a id=
1010"op-sr-assign">operator&gt;&gt;=</a>(size_type n)
1011</pre>
1012
1013<b>Effects:</b> Shifts the bits in this bitset to the right by
1014<tt>n</tt> bits. For each bit in the bitset, the bit at position
1015<tt>pos</tt> takes on the previous value of bit <tt>pos + n</tt>,
1016or zero if no such bit exists.<br />
1017 <b>Returns:</b> <tt>*this</tt>.<br />
1018 <b>Throws:</b> nothing.
1019
1020<hr />
1021<pre>
1022dynamic_bitset <a id=
1023"op-sl">operator&lt;&lt;</a>(size_type n) const
1024</pre>
1025
1026<b>Returns:</b> a copy of <tt>*this</tt> shifted to the left by
1027<tt>n</tt> bits. For each bit in the returned bitset, the bit at
1028position pos takes on the value of the bit at position <tt>pos -
1029n</tt> of this bitset, or zero if no such bit exists.<br />
1030 <b>Throws:</b> An allocation error if memory is exhausted
1031(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1032
1033<hr />
1034<pre>
1035dynamic_bitset <a id=
1036"op-sr">operator&gt;&gt;</a>(size_type n) const
1037</pre>
1038
1039<b>Returns:</b> a copy of <tt>*this</tt> shifted to the right by
1040<tt>n</tt> bits. For each bit in the returned bitset, the bit at
1041position pos takes on the value of the bit at position <tt>pos +
1042n</tt> of this bitset, or zero if no such bit exists.<br />
1043 <b>Throws:</b> An allocation error if memory is exhausted
1044(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1045
1046<hr />
1047<pre>
1048dynamic_bitset&amp; <a id="set1">set</a>()
1049</pre>
1050
1051<b>Effects:</b> Sets every bit in this bitset to 1.<br />
1052<b>Returns:</b> <tt>*this</tt><br />
1053<b>Throws:</b> nothing.
1054
1055<hr />
1056<pre>
1057dynamic_bitset&amp; <a id="flip1">flip</a>()
1058</pre>
1059
1060<b>Effects:</b> Flips the value of every bit in this bitset.<br />
1061<b>Returns:</b> <tt>*this</tt><br />
1062<b>Throws:</b> nothing.
1063
1064<hr />
1065<pre>
1066dynamic_bitset <a id="op-not">operator~</a>() const
1067</pre>
1068
1069<b>Returns:</b> a copy of <tt>*this</tt> with all of its bits
1070flipped.<br />
1071<b>Throws:</b> An allocation error if memory is exhausted
1072(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1073
1074<hr />
1075<pre>
1076dynamic_bitset&amp; <a id="reset1">reset</a>()
1077</pre>
1078
1079<b>Effects:</b> Clears every bit in this bitset.<br />
1080<b>Returns:</b> <tt>*this</tt><br />
1081<b>Throws:</b> nothing.
1082
92f5a8d4
TL
1083<hr />
1084<pre>
1085dynamic_bitset&amp; <a id=
1086"set3">set</a>(size_type n, size_type len, bool val);
1087</pre>
1088
1089<b>Precondition:</b> <tt>n + len &lt; this-&gt;size()</tt>.<br />
1090<b>Effects:</b> Sets every bit indexed from <tt>n</tt> to
1091<tt>n + len - 1</tt> inclusively if <tt>val</tt> is <tt>true</tt>, and
1092clears them if <tt>val</tt> is <tt>false</tt>. <br />
1093<b>Returns:</b> <tt>*this</tt>
1094
7c673cae
FG
1095<hr />
1096<pre>
1097dynamic_bitset&amp; <a id=
1098"set2">set</a>(size_type n, bool val = true)
1099</pre>
1100
1101<b>Precondition:</b> <tt>n &lt; this-&gt;size()</tt>.<br />
1102 <b>Effects:</b> Sets bit <tt>n</tt> if <tt>val</tt> is
1103<tt>true</tt>, and clears bit <tt>n</tt> if <tt>val</tt> is
1104<tt>false</tt>. <br />
1105 <b>Returns:</b> <tt>*this</tt>
1106
92f5a8d4
TL
1107<hr />
1108<pre>
1109dynamic_bitset&amp; <a id=
1110"reset3">reset</a>(size_type n, size_type len);
1111</pre>
1112
1113<b>Precondition:</b> <tt>n + len &lt; this-&gt;size()</tt>.<br />
1114<b>Effects:</b> Clears every bit indexed from <tt>n</tt> to
1115<tt>n + len - 1</tt> inclusively.<br />
1116<b>Returns:</b> <tt>*this</tt>
1117
7c673cae
FG
1118<hr />
1119<pre>
1120dynamic_bitset&amp; <a id="reset2">reset</a>(size_type n)
1121</pre>
1122
1123<b>Precondition:</b> <tt>n &lt; this-&gt;size()</tt>.<br />
1124<b>Effects:</b> Clears bit <tt>n</tt>.<br />
1125<b>Returns:</b> <tt>*this</tt>
1126
92f5a8d4
TL
1127<hr />
1128<pre>
1129dynamic_bitset&amp; <a id="flip3">flip</a>(size_type n, size_type len)
1130</pre>
1131
1132<b>Precondition:</b> <tt>n + len &lt; this-&gt;size()</tt>.<br />
1133<b>Effects:</b> Flips every bit indexed from <tt>n</tt> to
1134<tt>n + len - 1</tt> inclusively.<br />
1135<b>Returns:</b> <tt>*this</tt>
1136
7c673cae
FG
1137<hr />
1138<pre>
1139dynamic_bitset&amp; <a id="flip2">flip</a>(size_type n)
1140</pre>
1141
1142<b>Precondition:</b> <tt>n &lt; this-&gt;size()</tt>.<br />
1143<b>Effects:</b> Flips bit <tt>n</tt>.<br />
1144<b>Returns:</b> <tt>*this</tt>
1145
1146<hr />
1147<pre>
1148size_type <a id="size">size</a>() const
1149</pre>
1150
1151<b>Returns:</b> the number of bits in this bitset.<br />
1152<b>Throws:</b> nothing.
1153
1154<hr />
1155<pre>
1156size_type <a id="num_blocks">num_blocks</a>() const
1157</pre>
1158
1159<b>Returns:</b> the number of blocks in this bitset.<br />
1160<b>Throws:</b> nothing.
1161
1162<hr />
1163<pre>
1164size_type <a id="max_size">max_size</a>() const;
1165</pre>
1166
1167<b>Returns:</b> the maximum size of a <tt>dynamic_bitset</tt>
1168object having the same type as <tt>*this</tt>. Note that if
1169any <tt>dynamic_bitset</tt> operation causes <tt>size()</tt> to
1170exceed <tt>max_size()</tt> then the <i>behavior is undefined</i>.
1171<br /><br />[The semantics of this function could change slightly
1172when lib issue 197 will be closed]<br />
1173
1174<hr />
1175<pre>
1176bool <a id="empty">empty</a>() const;
1177</pre>
1178
1179<b>Returns:</b> <tt>true</tt> if <tt>this->size() == 0</tt>, <tt>false</tt>
1180otherwise. <i>Note</i>: not to be confused with <tt>none()</tt>, that has
1181different semantics.
1182
1183<hr />
1184<pre>
1185size_type <a id="capacity">capacity</a>() const;
1186</pre>
1187
1188<b>Returns:</b> The total number of elements that <tt>*this</tt> can hold without requiring
1189reallocation.<br />
1190<b>Throws:</b> nothing.
1191
1192<hr />
1193<pre>
1194void <a id="reserve">reserve</a>(size_type num_bits);
1195</pre>
1196
1197<b>Effects:</b> A directive that informs the bitset of a planned change in size, so that it can
1198manage the storage allocation accordingly. After reserve(), capacity() is greater or equal to the
1199argument of reserve() if reallocation happens; and equal to the previous value of capacity() otherwise.
1200Reallocation happens at this point if and only if the current capacity is less than the argument of
1201reserve(). <br />
1202<i>Note:</i> It does not change the size() of the bitset.<br />
1203<b>Postcondtitions:</b> <tt>this->capacity() >= num_bits</tt>.<br />
1204<b>Throws:</b> An allocation error if memory is exhausted
1205(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1206
1207<hr />
1208<pre>
1209void <a id="shrink_to_fit">shrink_to_fit</a>();
1210</pre>
1211
1212<b>Effects:</b> shrink_to_fit() is a request to reduce memory use by removing unused capacity.<br />
1213<i>Note:</i> It does not change the size() of the bitset.<br />
1214<b>Throws:</b> An allocation error if memory is exhausted
1215(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1216
1217<hr />
1218<pre>
1219size_type <a id="count">count</a>() const
1220</pre>
1221
1222<b>Returns:</b> the number of bits in this bitset that are
1223set.<br />
1224<b>Throws:</b> nothing.
1225
1226<hr />
1227<pre>
1228bool <a id="all">all</a>() const
1229</pre>
1230
1231<b>Returns:</b> <tt>true</tt> if all bits in this bitset are set or
1232if <tt>size() == 0</tt>, and otherwise returns <tt>false</tt>.<br />
1233<b>Throws:</b> nothing.
1234
1235<hr />
1236<pre>
1237bool <a id="any">any</a>() const
1238</pre>
1239
1240<b>Returns:</b> <tt>true</tt> if any bits in this bitset are set,
1241and otherwise returns <tt>false</tt>.<br />
1242<b>Throws:</b> nothing.
1243
1244<hr />
1245<pre>
1246bool <a id="none">none</a>() const
1247</pre>
1248
1249<b>Returns:</b> <tt>true</tt> if no bits are set, and otherwise
1250returns <tt>false</tt>.<br />
1251<b>Throws:</b> nothing.
1252
1253<hr />
1254<pre>
1255bool <a id="test">test</a>(size_type n) const
1256</pre>
1257
1258<b>Precondition:</b> <tt>n &lt; this-&gt;size()</tt>.<br />
1259 <b>Returns:</b> <tt>true</tt> if bit <tt>n</tt> is set and
1260<tt>false</tt> is bit <tt>n</tt> is 0.
1261
1262<hr />
1263<pre>
1264bool <a id="test">test_set</a>(size_type n, bool val = true)
1265</pre>
1266
1267<b>Precondition:</b> <tt>n &lt; this-&gt;size()</tt>.<br />
1268 <b>Effects:</b> Sets bit <tt>n</tt> if <tt>val</tt> is
1269<tt>true</tt>, and clears bit <tt>n</tt> if <tt>val</tt> is
1270<tt>false</tt>. <br />
1271 <b>Returns:</b> <tt>true</tt> if the previous state of bit
1272<tt>n</tt> was set and <tt>false</tt> is bit <tt>n</tt> is 0.
1273
1274<hr />
1275<pre>
1276reference <a id="bracket">operator[]</a>(size_type n)
1277</pre>
1278
1279<b>Precondition:</b> <tt>n &lt; this-&gt;size()</tt>.<br />
1280 <b>Returns:</b> a <tt>reference</tt> to bit <tt>n</tt>. Note
1281that <tt>reference</tt> is a proxy class with an assignment
1282operator and a conversion to <tt>bool</tt>, which allows you to
1283use <tt>operator[]</tt> for assignment. That is, you can write
1284both <tt>x = b[n]</tt> and <tt>b[n] = x</tt>. However, in many
1285other respects the proxy is not the same as the true reference
1286type <tt>bool&amp;</tt>.
1287
1288<hr />
1289<pre>
1290bool <a id="const-bracket">operator[]</a>(size_type n) const
1291</pre>
1292
1293<b>Precondition:</b> <tt>n &lt; this-&gt;size()</tt>.<br />
1294<b>Returns:</b> The same as <tt>test(n)</tt>.
1295
1296<hr />
1297<pre>
1298unsigned long <a id="to_ulong">to_ulong</a>() const
1299</pre>
1300
1301<b>Returns:</b> The numeric value corresponding to the bits in <tt>*this</tt>.
1302<br />
1303<b>Throws:</b> <tt>std::overflow_error</tt> if that value is too large to
1304be represented in an <tt>unsigned long</tt>, i.e. if <tt>*this</tt> has
1305any non-zero bit at a position <tt>&gt;=
1306std::numeric_limits&lt;unsigned long&gt;::digits</tt>.
1307
1308<hr />
1309<pre>
1310bool <a id=
1311"is_subset_of">is_subset_of</a>(const dynamic_bitset&amp; a) const
1312</pre>
1313
1314<b>Requires:</b> <tt>this-&gt;size() == a.size()</tt><br />
1315<b>Returns:</b> true if this bitset is a subset of bitset
1316<tt>a</tt>. That is, it returns true if, for every bit that is
1317set in this bitset, the corresponding bit in bitset <tt>a</tt> is
1318also set. Otherwise this function returns false.<br />
1319<b>Throws:</b> nothing.
1320
1321<hr />
1322<pre>
1323bool <a id=
1324"is_proper_subset_of">is_proper_subset_of</a>(const dynamic_bitset&amp; a) const
1325</pre>
1326
1327<b>Requires:</b> <tt>this-&gt;size() == a.size()</tt><br />
1328<b>Returns:</b> true if this bitset is a proper subset of bitset
1329<tt>a</tt>. That is, it returns true if, for every bit that is
1330set in this bitset, the corresponding bit in bitset <tt>a</tt> is
1331also set and if <tt>this-&gt;count() &lt; a.count()</tt>.
1332Otherwise this function returns false.<br />
1333<b>Throws:</b> nothing.
1334
1335<hr />
1336<pre>
1337bool <a id=
1338"intersects">intersects</a>(const dynamic_bitset&amp; a) const
1339</pre>
1340
1341<b>Requires:</b> <tt>this-&gt;size() == a.size()</tt><br />
1342<b>Returns:</b> true if this bitset and <tt>a</tt> intersect.
1343That is, it returns true if, there is a bit which is set in this
1344bitset, such that the corresponding bit in bitset <tt>a</tt> is
1345also set. Otherwise this function returns false.<br />
1346<b>Throws:</b> nothing.
1347
1348<hr />
1349<pre>
1350size_type <a id = "find_first">find_first</a>() const;
1351</pre>
1352
1353<b>Returns:</b> the lowest index <tt>i</tt> such as bit <tt>i</tt>
1354is set, or <tt>npos</tt> if <tt>*this</tt> has no on bits.
1355
1356<hr />
1357<pre>
1358size_type <a id="find_next">find_next</a>(size_type pos) const;
1359</pre>
1360
1361<b>Returns:</b> the lowest index <tt>i</tt> greater than
1362<tt>pos</tt> such as bit <tt>i</tt> is set, or <tt>npos</tt> if
1363no such index exists.
1364
1365<hr />
1366<pre>
1367bool <a id=
1368"op-equal">operator==</a>(const dynamic_bitset&amp; rhs) const
1369</pre>
1370
1371<b>Returns:</b> <tt>true</tt> if <tt>this-&gt;size() ==
1372rhs.size()</tt> and if for all <tt>i</tt> in the range
1373<tt>[0,rhs.size())</tt>, <tt>(*this)[i] == rhs[i]</tt>. Otherwise
1374returns <tt>false</tt>.<br />
1375 <b>Throws:</b> nothing.<br />
1376 (Required by <a href=
92f5a8d4 1377"https://boost.org/sgi/stl/EqualityComparable.html">Equality
7c673cae
FG
1378Comparable</a>.)
1379
1380<hr />
1381<pre>
1382bool <a id=
1383"op-not-equal">operator!=</a>(const dynamic_bitset&amp; rhs) const
1384</pre>
1385
1386<b>Returns:</b> <tt>!((*this) == rhs)</tt><br />
1387<b>Throws:</b> nothing.<br />
1388(Required by <a href=
92f5a8d4 1389"https://boost.org/sgi/stl/EqualityComparable.html">Equality
7c673cae
FG
1390Comparable</a>.)
1391
1392<hr />
1393<pre>
1394bool <a id=
1395"op-less">operator&lt;</a>(const dynamic_bitset&amp; rhs) const
1396</pre>
1397
1398<b>Returns:</b> <tt>true</tt> if this bitset is lexicographically
1399less than <tt>rhs</tt>, and returns <tt>false</tt> otherwise.
1400(See the description of <a href=
92f5a8d4 1401"https://boost.org/sgi/stl/lexicographical_compare.html">lexicographical_compare</a>
7c673cae
FG
1402for a definition of lexicographic ordering). <br />
1403<b>Throws:</b> nothing.<br />
1404(Required by <a href=
92f5a8d4 1405"https://boost.org/sgi/stl/LessThanComparable.html">Less Than
7c673cae
FG
1406Comparable</a>.)
1407
1408<hr />
1409<pre>
1410bool <a id=
1411"op-greater">operator&gt;</a>(const dynamic_bitset&amp; rhs) const
1412</pre>
1413
1414<b>Returns:</b> <tt>!((*this) &lt; rhs || (*this) ==
1415rhs)</tt><br />
1416<b>Throws:</b> nothing.<br />
1417(Required by <a href=
92f5a8d4 1418"https://boost.org/sgi/stl/LessThanComparable.html">Less Than
7c673cae
FG
1419Comparable</a>.)
1420
1421<hr />
1422<pre>
1423bool <a id=
1424"op-less-equal">operator&lt;=</a>(const dynamic_bitset&amp; rhs) const
1425</pre>
1426
1427<b>Returns:</b> <tt>(*this) &lt; rhs || (*this) == rhs</tt><br />
1428<b>Throws:</b> nothing.<br />
1429(Required by <a href=
92f5a8d4 1430"https://boost.org/sgi/stl/LessThanComparable.html">Less Than
7c673cae
FG
1431Comparable</a>.)
1432
1433<hr />
1434<pre>
1435bool <a id=
1436"op-greater-equal">operator&gt;=</a>(const dynamic_bitset&amp; rhs) const
1437</pre>
1438
1439<b>Returns:</b> <tt>(*this) &gt; rhs || (*this) == rhs</tt><br />
1440<b>Throws:</b> nothing.<br />
1441(Required by <a href=
92f5a8d4 1442"https://boost.org/sgi/stl/LessThanComparable.html">Less Than
7c673cae
FG
1443Comparable</a>.)
1444
1445<hr />
1446<h3><a id="non-member-functions">Non-Member Functions</a></h3>
1447
1448<hr />
1449<pre>
1450dynamic_bitset <a id=
1451"op-and">operator&amp;</a>(const dynamic_bitset&amp; a, const dynamic_bitset&amp; b)
1452</pre>
1453
1454<b>Requires:</b> <tt>a.size() == b.size()</tt><br />
1455<b>Returns:</b> A new bitset that is the bitwise-AND of the
1456bitsets <tt>a</tt> and <tt>b</tt>.<br />
1457<b>Throws:</b> An allocation error if memory is exhausted
1458(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1459
1460<hr />
1461<pre>
1462dynamic_bitset <a id=
1463"op-or">operator|</a>(const dynamic_bitset&amp; a, const dynamic_bitset&amp; b)
1464</pre>
1465
1466<b>Requires:</b> <tt>a.size() == b.size()</tt><br />
1467<b>Returns:</b> A new bitset that is the bitwise-OR of the
1468bitsets <tt>a</tt> and <tt>b</tt>.<br />
1469<b>Throws:</b> An allocation error if memory is exhausted
1470(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1471
1472<hr />
1473<pre>
1474dynamic_bitset <a id=
1475"op-xor">operator^</a>(const dynamic_bitset&amp; a, const dynamic_bitset&amp; b)
1476</pre>
1477
1478<b>Requires:</b> <tt>a.size() == b.size()</tt><br />
1479<b>Returns:</b> A new bitset that is the bitwise-XOR of the
1480bitsets <tt>a</tt> and <tt>b</tt>.<br />
1481<b>Throws:</b> An allocation error if memory is exhausted
1482(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1483
1484<hr />
1485<pre>
1486dynamic_bitset <a id=
1487"op-sub">operator-</a>(const dynamic_bitset&amp; a, const dynamic_bitset&amp; b)
1488</pre>
1489
1490<b>Requires:</b> <tt>a.size() == b.size()</tt><br />
1491<b>Returns:</b> A new bitset that is the set difference of the
1492bitsets <tt>a</tt> and <tt>b</tt>.<br />
1493<b>Throws:</b> An allocation error if memory is exhausted
1494(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1495
1496<hr />
1497<pre>
1498template &lt;typename CharT, typename Alloc&gt;
1499void <a id=
1500"to_string">to_string</a>(const dynamic_bitset&lt;Block, Allocator&gt;&amp; b,
1501 <a href=
92f5a8d4 1502"https://boost.org/sgi/stl/basic_string.html">std::basic_string</a>&lt;Char,Traits,Alloc&gt;&amp; s)
7c673cae
FG
1503</pre>
1504
1505<b>Effects:</b> Copies a representation of <tt>b</tt> into the
1506string <tt>s</tt>. A character in the string is <tt>'1'</tt> if
1507the corresponding bit is set, and <tt>'0'</tt> if it is not.
1508Character position <tt>i</tt> in the string corresponds to bit
1509position <tt>b.size() - 1 - i</tt>. <br />
1510 <b>Throws:</b> If memory is exhausted, the string will throw an
1511allocation error.<br />
1512 <b>Rationale:</b> This function is not a member function taking
1513zero arguments and returning a string for a couple reasons.
1514First, this version can be slighly more efficient because the
1515string is not copied (due to being passed by value). Second, as a
1516member function, to allow for flexibility with regards to the
1517template parameters of <tt>basic_string</tt>, the member function
1518would require explicit template parameters. Few C++ programmers
1519are familiar with explicit template parameters, and some C++
1520compilers do not handle them properly.
1521
1522<hr />
1523<pre>
1524template &lt;typename Block, typename Alloc, typename BlockOutputIterator&gt;
1525void <a id=
1526"to_block_range">to_block_range</a>(const dynamic_bitset&lt;Block, Alloc&gt;&amp; b, BlockOutputIterator result)
1527</pre>
1528
1529<b>Effects:</b> Writes the bits of the bitset into the iterator
1530<tt>result</tt> a block at a time. The first block written
1531represents the bits in the position range
1532<tt>[0,bits_per_block)</tt> in the bitset, the second block
1533written the bits in the range
1534<tt>[bits_pre_block,2*bits_per_block)</tt>, and so on. For each
1535block <tt>bval</tt> written, the bit <tt>(bval &gt;&gt; i) &amp;
15361</tt> corresponds to the bit at position <tt>(b * bits_per_block
1537+ i)</tt> in the bitset.<br />
1538 <b>Requires:</b> The type <tt>BlockOutputIterator</tt> must be a
1539model of <a href=
92f5a8d4 1540"https://boost.org/sgi/stl/OutputIterator.html">Output
7c673cae
FG
1541Iterator</a> and its <tt>value_type</tt> must be the same type as
1542<tt>Block</tt>. Further, the size of the output range must be
1543greater or equal <tt>b.num_blocks()</tt>.
1544
1545<hr />
1546<pre>
1547template &lt;typename BlockIterator, typename Block, typename Alloc&gt;
1548void <a id=
1549"from_block_range">from_block_range</a>(BlockIterator first,
1550 BlockIterator last, const dynamic_bitset&lt;Block, Alloc&gt;&amp; b)
1551</pre>
1552
1553<b>Effects:</b> Reads blocks from the iterator range into the
1554bitset. <br />
1555 <b>Requires:</b> The type <tt>BlockIterator</tt> must be a model
92f5a8d4 1556of <a href="https://boost.org/sgi/stl/InputIterator.html">Input
7c673cae
FG
1557Iterator</a> and its <tt>value_type</tt> must be the same type as
1558<tt>Block</tt>. The size of the iterator range must be less or
1559equal to <tt>b.num_blocks()</tt>.
1560
1561<hr />
1562<pre>
1563template &lt;typename Char, typename Traits, typename Block, typename Alloc&gt;
1564basic_ostream&lt;Char, Traits&gt;&amp;
1565<a id=
1566"op-out">operator&lt;&lt;</a>(basic_ostream&lt;Char, Traits&gt;&amp; os, const dynamic_bitset&lt;Block, Alloc&gt;&amp; b)
1567</pre>
1568
1569<b>Effects:</b> Inserts a textual representation of b into the stream
1570<tt>os</tt> (highest bit first). Informally, the output is the same as doing
1571
1572<pre>
1573std::basic_string&lt;Char, Traits&gt; s;
1574boost::to_string(x, s):
1575os &lt;&lt; s;
1576</pre>
1577
1578except that the stream inserter takes into accout the locale imbued into
1579<tt>os</tt>, which <tt>boost::to_string()</tt> can't do. Here is a more
1580precise specification, given in terms of "as if" rule: first, for each
1581valid position i into the bitset <tt>b</tt> let's put:
1582
1583 <tt>character_of(b[i)]) = b[i]? os.widen('1') : os.widen('0');</tt>
1584
1585Let also <tt>s</tt> be a <tt>std::basic_string&lt;Char, Traits&gt;</tt>
1586object, having length <tt>b.size()</tt> and such as, for each <tt>i</tt>
1587in <tt>[0, b.size())</tt>,
1588
1589 <tt>s[i] is character_of(b[i])</tt>
1590
1591Then, the output, the effects on <tt>os</tt> and the exception behavior
1592is the same as outputting the object <tt>s</tt> to <tt>os</tt> (same
1593width, same exception mask, same padding, same setstate() logic)
1594<br />
1595<b>Returns:</b> os <br />
1596<b>Throws:</b> <tt>std::ios_base::failure</tt> if there is a
1597problem writing to the stream.
1598
1599<hr />
1600<pre>
1601template &lt;typename Char, typename Traits, typename Block, typename Alloc&gt;
1602std::basic_istream&lt;Char,Traits&gt;&amp;
1603<a id=
1604"op-in">operator&gt;&gt;</a>(std::basic_istream&lt;Char,Traits&gt;&amp; is, dynamic_bitset&lt;Block, Alloc&gt;&amp; b)
1605</pre>
1606
1607<b>Effects:</b> Extracts a <tt>dynamic_bitset</tt> from an input stream.
1608<br /><br />
1609 <i>Definitions:</i><br /><br />
1610 Let <i>Tr</i> be the traits_type of <i>is</i>. Then:
1611 <ol>
1612 <li>
1613 A (non-eof) character <tt>c</tt> extracted from <tt>is</tt>
1614 is a <i>bitset digit</i> if and only if either Tr::eq(c, is.widen('0')) or
1615 Tr::eq(c, is.widen('1')) return true.
1616 </li>
1617 <li>If c is a bitset digit, it's <i>corresponding bit value</i> is 0 if
1618 Tr::eq(c, is.widen('0')) is true, 1 otherwise.
1619 </li>
1620 </ol>
1621
1622The function begins by constructing a <tt>sentry</tt> object <tt>k</tt> as if <tt>k</tt>
1623were constructed by
1624
1625 <tt>typename std::basic_istream&lt;Char, Traits&gt;::sentry k(is)</tt>.
1626
1627If <tt>bool(k)</tt> is true, it calls <tt>b.clear()</tt>
1628then attempts to extract characters from <tt>is</tt>. For each character c
1629that is a <i>bitset digit</i> the <i>corresponding bit value</i> is
1630appended to the less significant end of <tt>b</tt> (appending may throw).
1631If <tt>is.width()</tt> is greater than zero and smaller than <tt>b.max_size()</tt>
1632then the maximum number <tt>n</tt> of bits appended is <tt>is.width()</tt>;
1633otherwise <tt>n</tt> = <tt>b.max_size()</tt>.
1634
1635Unless the extractor is exited via an exception, characters are extracted (and
1636corresponding bits appended) until any of the following occurs:<br />
1637
1638<ul>
1639<li> <tt>n</tt> bits are stored into the bitset;</li>
1640<li> end-of-file, or an error, occurs on the input sequence;</li>
1641<li> the next available input character isn't a bitset digit</li>
1642</ul>
1643<br /> If no exception caused the function to exit then <tt>is.width(0)</tt> is
1644 called, regardless of how many characters were actually extracted. The
1645 sentry object k is destroyed.
1646<br />
1647<br />If the function extracts no characters[???], it calls is.setstate(std::ios::failbit),
1648 which may throw <tt>std::ios_base::failure</tt>.
1649
1650
1651<br />------
1652
1653
1654<br />
1655<b>Throws:</b> An allocation error if memory is exhausted
1656(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
1657A <tt>std::ios_base::failure</tt> if there is a problem reading
1658from the stream.
1659
1660<hr />
1661<h3><a id="exception-guarantees">Exception guarantees</a></h3>
1662
1663All of <tt>dynamic_bitset</tt> functions offer at least the basic
1664exception guarantee.
1665
1666<hr />
1667<h3><a id="changes-from-previous-ver">Changes from previous version(s)</a></h3>
1668
1669<h4><i>Changes in Boost 1.56.0</i></h4>
1670<ul>
1671<li>Support for C++11 move constructors.</li>
1672<li>Warning fixes on MSVC 2013.</li>
1673<li>Support for C++11 minimal allocators.</li>
1674<li>Add noexcept specifications.</li>
1675</ul>
1676
1677<h4><i>Changes in Boost 1.37.0</i></h4>
1678<ul>
1679<li>The constructor from a block range implements a "do the right thing"
1680behavior, a la standard sequences.</li>
1681</ul>
1682
1683<!-- Changes from Boost 1.31.0 -->
1684<h4><i>Changes from Boost 1.31.0</i></h4>
1685<ul>
1686<li>
1687The stream extractor has completely different semantics: as natural
1688for a dynamic structure, it now expands the bitset as needed during
1689extraction. The new behaviour mimics that of the <tt>basic_string</tt>
1690extractor but there are some differences the user should be aware of;
1691so, please, check the <a href="#op-in">documentation</a>. (One
1692difference concerns the case where <code>stream.width() &gt;
1693 bitset.max_size() &gt; 0</code>. In that circumstance the
1694extractor of <tt>dynamic_bitset</tt> never attempts to extract more
1695than <tt>max_size()</tt> characters, whereas the extractor of
1696<tt>basic_string</tt> goes on and, on conforming implementations,
1697eventually throws a <tt>length_error</tt> exception. Note: That's what
1698the standard mandates -see especially <a
1699 href="http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#83">library
1700 issue 83</a>- but not all implementations conform)
1701<br /><br />
1702The stream extractor is now also "exception-aware" in the sense that
1703it works correctly when setting exception masks on the stream.
1704<br /><br />
1705</li>
1706<li>
1707Several member functions (<tt>empty()</tt>, <tt>find_first()</tt>
1708, <tt>find_next()</tt>, <tt>get_allocator()</tt>, <tt>intersects()</tt>
1709, <tt>max_size()</tt> <!--, <tt>reserve()</tt>, <tt>capacity()</tt> -->)
1710have been added.
1711</li>
1712<li>
1713The constructor from <tt>basic_string</tt> has a new parameter that was totally
1714forgotten before.
1715</li>
1716
1717</ul>
1718<i>Technicalities and minor changes</i>
1719<ul>
1720<li>
1721The class <tt>reference</tt> has been reimplemented so that
1722dynamic_bitset's references behave more like references to standard
1723container elements. In particular it is now guaranteed that they
1724cannot be invalidated from a standard library swap() function
1725applied to their corresponding <tt>dynamic_bitset</tt>s.
1726</li>
1727</ul>
1728<i>General improvements</i>
1729<ul>
1730<li>
1731Several optimizations to member and non-member functions and to the
1732nested class <tt>reference</tt>.
1733</li>
1734</ul>
1735
1736<hr />
1737<h3><a id="see-also">See also</a></h3>
1738
1739<tt><a href=
92f5a8d4 1740"https://boost.org/sgi/stl/bitset.html">std::bitset</a></tt>,
7c673cae 1741<tt><a href=
92f5a8d4 1742"https://boost.org/sgi/stl/Vector.html">std::vector</a></tt>,
7c673cae
FG
1743
1744<h3><a id="acknowledgements">Acknowledgements</a></h3>
1745
1746<p>We would like to thank the Boost community for putting in the
1747time to review and accept this library. This library is much
1748better than it ever would have been due to all the suggestions
1749from Boost members. We especially thank Matt Marcus for taking on
1750the task of review manager. Also, a special thanks goes to
1751James Kanze for his invaluable help with the internationalization
1752issues.</p>
1753
1754<table summary="Copyright"> <tr> <td>Copyright &copy; 2001</td>
1755<td><a href="http://www.boost.org/people/jeremy_siek.htm">Jeremy
1756Siek</a>, Indiana University (<a
1757href="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</a>)<br /> <a
1758href="http://freshsources.com">Chuck Allison</a>, Senior Editor,
1759C/C++ Users Journal (<a
1760href="mailto:cda@freshsources.com">cda@freshsources.com</a>)<br
1761/></td> </tr> <tr>
1762<td>Copyright &copy; 2003-2004, 2008</td> <td><a
1763 href="http://gennaro-prota.50webs.com/">Gennaro Prota</a>
1764 (name.surname yahoo.com)</td>
1765</tr>
1766<tr>
1767<td>Copyright &copy; 2014</td>
1768<td>Ahmed Charles (<a href="mailto:acharles@outlook.com">acharles@outlook.com</a>)</td>
1769</tr>
1770<tr>
1771<td>Copyright &copy; 2014</td>
92f5a8d4 1772<td>Glen Fernandes (<a href="mailto:glenjofe@gmail.com">glenjofe@gmail.com</a>)</td>
7c673cae
FG
1773</tr>
1774<tr>
1775<td>Copyright &copy; 2014</td>
1776<td>Riccardo Marcangelo (<a href="mailto:ricky.65@outlook.com">ricky.65@outlook.com</a>)</td>
1777</tr>
1778</table>
1779<br />
1780<div class="legalnotice">
1781 Distributed under the Boost Software License, Version 1.0.
1782 (See accompanying file <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a>
1783 or copy at <a class="ulink" href="http://www.boost.org/LICENSE_1_0.txt">
1784http://www.boost.org/LICENSE_1_0.txt</a>)
1785</div>
1786
1787
1788</div>
1789</div>
1790</div>
1791</div>
1792</div>
1793</div>
1794</body>
1795<!-- LocalWords: dynamic bitset alt gif iostream hpp int bitsets const ul ulong -->
1796<!-- LocalWords: STL LessThan alloc num typename BlockInputIterator html pos -->
1797<!-- LocalWords: npos bool rhs OR's XOR's val CharT istream ostream os siek -->
1798<!-- LocalWords: htm namespace enum sizeof BlockOutputIterator fwd ith jth -->
1799</html>