1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
7 Templated Circular Buffer Container
9 <link rel="stylesheet" href="../../../boost.css" type="text/css">
12 <table id="title" border="0">
16 Templated Circular Buffer Container
19 circular_buffer<T, Alloc>
23 <a href="../../../"><img src="../../../boost.png" width="277" height="86" border="0" alt="Boost"></a>
32 <a href="#description">Description</a>
35 <a href="#briefexample">Introductory Example</a>
38 <a href="#synopsis">Synopsis</a>
41 <a href="#rationale">Rationale</a>
46 <a href="#threadsafety">Thread-Safety</a>
49 <a href="#overwrite">Overwrite Operation</a>
52 <a href="#fullbuffer">Writing to a Full Buffer</a>
55 <a href="#emptybuffer">Reading/Removing from an Empty Buffer</a>
58 <a href="#iteratorinvalidation">Iterator Invalidation</a>
63 <a href="#caveats">Caveats</a>
66 <a href="#debug">Debug Support</a>
69 <a href="#interprocess">Compatibility with Interprocess library</a>
72 <a href="#examples">More Examples</a>
75 <a href="#header">Header Files</a>
78 <a href="#model">Modelled Concepts</a>
81 <a href="#parameters">Template Parameters</a>
84 <a href="#types">Public Types</a>
87 <a href="#constructors">Constructors and Destructor</a>
90 <a href="#methods">Public Member Functions</a>
93 <a href="#functions">Standalone Functions</a>
96 <a href="#notes">Notes</a>
99 <a href="#see">See also</a>
102 <a href="#ack">Acknowledgements</a>
105 <a href="#relnotes">Release Notes</a>
108 <table id="table_figure" align="right" border="0">
111 <img src="circular_buffer.png" width="300" height="332" alt="Circular Buffer">
116 <table id="table_figure_desc" cellpadding="5" align="right" border="0">
122 The circular buffer (for someone known as <i>ring</i> or <i>cyclic buffer</i>).
130 <a name="description" id="description">Description</a>
133 In general the term <i>circular buffer</i> refers to an area in memory which is used to store incoming data. When
134 the buffer is filled, new data is written starting at the beginning of the buffer and overwriting the old. (Also
138 The <code>circular_buffer</code> is a STL compliant container. It is a kind of sequence similar to <code><a href=
139 "http://www.sgi.com/tech/stl/List.html">std::list</a></code> or <code><a href=
140 "http://www.sgi.com/tech/stl/Deque.html">std::deque</a></code>. It supports random access iterators, constant
141 time insert and erase operations at the beginning or the end of the buffer and interoperability with
142 <code>std</code> algorithms. The <code>circular_buffer</code> is especially designed to provide fixed capacity
143 storage. When its capacity is exhausted, newly inserted elements will cause elements either at the beginning or
144 end of the buffer (depending on what insert operation is used) to be overwritten.
147 The <code>circular_buffer</code> only allocates memory when created, when the capacity is adjusted explicitly, or
148 as necessary to accommodate resizing or assign operations. On the other hand, there is also a <code><a href=
149 "space_optimized.html">circular_buffer_space_optimized</a></code> available. It is an adaptor of the
150 <code>circular_buffer</code> which does not allocate memory at once when created, rather it allocates memory as
154 <a name="briefexample" id="briefexample">Introductory Example</a>
157 A brief example using the <code>circular_buffer</code>:
160 #include <boost/circular_buffer.hpp>
162 int main(int /*argc*/, char* /*argv*/[]) {
164 // Create a circular buffer with a capacity for 3 integers.
165 boost::circular_buffer<int> cb(3);
167 // Insert some elements into the buffer.
172 int a = cb[0]; // a == 1
173 int b = cb[1]; // b == 2
174 int c = cb[2]; // c == 3
176 // The buffer is full now, pushing subsequent
177 // elements will overwrite the front-most elements.
179 cb.push_back(4); // Overwrite 1 with 4.
180 cb.push_back(5); // Overwrite 2 with 5.
182 // The buffer now contains 3, 4 and 5.
188 // Elements can be popped from either the front or the back.
190 cb.pop_back(); // 5 is removed.
191 cb.pop_front(); // 3 is removed.
193 int d = cb[0]; // d == 4
199 <a name="synopsis" id="synopsis">Synopsis</a>
201 <div id="srcdoc_synopsis">
202 <table id="table_synopsis" border="0" cellpadding="10">
208 template <class <a href="#templateparam_T">T</a>, class <a href="#templateparam_Alloc">Alloc</a>>
209 class circular_buffer
212 typedef typename Alloc::value_type <a href=
213 "#classboost_1_1circular__buffer_1cbdd7ca87e147c08cd2be267eefd6540">value_type</a>;
214 typedef typename Alloc::pointer <a href=
215 "#classboost_1_1circular__buffer_14ff917f8a6131ec18e91606727592a9c">pointer</a>;
216 typedef typename Alloc::const_pointer <a href=
217 "#classboost_1_1circular__buffer_190f7c6bcb624ad507de546366f49028a">const_pointer</a>;
218 typedef typename Alloc::reference <a href=
219 "#classboost_1_1circular__buffer_1f38a9bc64d84757c661c2542ff9a7f65">reference</a>;
220 typedef typename Alloc::const_reference <a href=
221 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a>;
222 typedef typename Alloc::difference_type <a href=
223 "#classboost_1_1circular__buffer_15313e723fa85d73db5826f8b722aa2a9">difference_type</a>;
224 typedef typename Alloc::size_type <a href=
225 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a>;
226 typedef Alloc <a href="#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>;
227 typedef <i>implementation-defined</i> <a href=
228 "#classboost_1_1circular__buffer_15cab6d46f03c40d1e52d41843319ddb9">const_iterator</a>;
229 typedef <i>implementation-defined</i> <a href=
230 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a>;
231 typedef boost::reverse_iterator<const_iterator> <a href=
232 "#classboost_1_1circular__buffer_1c7317701b511bc5f7a663b06b53e2b73">const_reverse_iterator</a>;
233 typedef boost::reverse_iterator<iterator> <a href=
234 "#classboost_1_1circular__buffer_1002fb890dded89e75dfeb6f021fb58a5">reverse_iterator</a>;
235 typedef std::pair<pointer, size_type> <a href=
236 "#classboost_1_1circular__buffer_126d279f91fef717e25459a0817ff242f">array_range</a>;
237 typedef std::pair<const_pointer, size_type> <a href=
238 "#classboost_1_1circular__buffer_11885d7f475b7e7a74c95b2448d243025">const_array_range</a>;
239 typedef size_type <a href="#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a>;
242 "#classboost_1_1circular__buffer_1e53e744d2f94a2bcbfcdb219a9d93300">circular_buffer</a>(const allocator_type& alloc = allocator_type());
244 "#classboost_1_1circular__buffer_18f1606a26fead923c2cbe068a74e28b6">circular_buffer</a>(capacity_type buffer_capacity, const allocator_type& alloc = allocator_type());
246 "#classboost_1_1circular__buffer_1fdace8f110d5b7a17c02020757f06fe8">circular_buffer</a>(size_type n, const_reference item, const allocator_type& alloc = allocator_type());
248 "#classboost_1_1circular__buffer_104dc644486d835b56aa479ec48b52230">circular_buffer</a>(capacity_type buffer_capacity, size_type n, const_reference item, const allocator_type& alloc = allocator_type());
250 "#classboost_1_1circular__buffer_1e515d8a951eeb18b8cc930300e7e13bd">circular_buffer</a>(const circular_buffer<T, Alloc>& cb);
251 template <class InputIterator>
253 "#classboost_1_1circular__buffer_1744ec06b06a5a723386b645a29cb8ed2">circular_buffer</a>(InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
254 template <class InputIterator>
256 "#classboost_1_1circular__buffer_1a851f75f4a85b1a2b1a241904d21503f">circular_buffer</a>(capacity_type buffer_capacity, InputIterator first, InputIterator last, const allocator_type& alloc = allocator_type());
257 <a href="#classboost_1_1circular__buffer_164250ffbbbdbc62b99e8301fc195b80c">~circular_buffer</a>();
259 allocator_type <a href=
260 "#classboost_1_1circular__buffer_1a20b7d0e7a4da0af13286df9f53d660c">get_allocator</a>() const;
261 allocator_type& <a href="#classboost_1_1circular__buffer_1af7758a36ac2f84a3024b50b4fc7e098">get_allocator</a>();
262 iterator <a href="#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin</a>();
263 iterator <a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end</a>();
264 const_iterator <a href="#classboost_1_1circular__buffer_10640d3d41c13b6089b6f169224cf1038">begin</a>() const;
265 const_iterator <a href="#classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac">end</a>() const;
266 reverse_iterator <a href="#classboost_1_1circular__buffer_1db3d6b10b6763549f54d2627228fa7aa">rbegin</a>();
267 reverse_iterator <a href="#classboost_1_1circular__buffer_1cff9236a50107188b8942847a4dc2697">rend</a>();
268 const_reverse_iterator <a href=
269 "#classboost_1_1circular__buffer_1765d91bf48341907418433a1e3aab026">rbegin</a>() const;
270 const_reverse_iterator <a href="#classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3">rend</a>() const;
272 "#classboost_1_1circular__buffer_1d219f0d3203fb43b964a8cf63f1865cd">operator[]</a>(size_type index);
273 const_reference <a href=
274 "#classboost_1_1circular__buffer_1eb0a7fe7f8a56a4dc4c933b93adfcef4">operator[]</a>(size_type index) const;
275 reference <a href="#classboost_1_1circular__buffer_1cd84838cb4fffb6c113fd0297e502edc">at</a>(size_type index);
276 const_reference <a href=
277 "#classboost_1_1circular__buffer_1b233a298f5845a0fcf2ecc56f4170810">at</a>(size_type index) const;
278 reference <a href="#classboost_1_1circular__buffer_10d5fdeabeb352f47d1f7bb1ea8d9819f">front</a>();
279 reference <a href="#classboost_1_1circular__buffer_1d985d974020f88bb4255d8edbae0a30a">back</a>();
280 const_reference <a href="#classboost_1_1circular__buffer_10df8595d83bb9d8a7ce50aabc678f90b">front</a>() const;
281 const_reference <a href="#classboost_1_1circular__buffer_1027201797868c6274feb6712f670a132">back</a>() const;
282 array_range <a href="#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one</a>();
283 array_range <a href="#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two</a>();
284 const_array_range <a href="#classboost_1_1circular__buffer_10f4b157e27b1170a571417986b239945">array_one</a>() const;
285 const_array_range <a href="#classboost_1_1circular__buffer_1bb8eb0f298ad2012c55c5303e1f174d5">array_two</a>() const;
286 pointer <a href="#classboost_1_1circular__buffer_1ea728bf57f91aa8946eddf76ce816a4e">linearize</a>();
287 bool <a href="#classboost_1_1circular__buffer_120f64448dc0723cc68c1096f6b00bc0a">is_linearized</a>() const;
289 "#classboost_1_1circular__buffer_1c591bb9e271b10b5240afcff3bd2c619">rotate</a>(const_iterator new_begin);
290 size_type <a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size</a>() const;
291 size_type <a href="#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size</a>() const;
292 bool <a href="#classboost_1_1circular__buffer_15be1c2a005ec9828549ef6dd7ebed583">empty</a>() const;
293 bool <a href="#classboost_1_1circular__buffer_1fd0eef8ba91210d1575404b7e3e8207a">full</a>() const;
294 size_type <a href="#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve</a>() const;
295 capacity_type <a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity</a>() const;
297 "#classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f">set_capacity</a>(capacity_type new_capacity);
299 "#classboost_1_1circular__buffer_180c2e2e66a8fa9d0b7adc1b54921a8c3">resize</a>(size_type new_size, const_reference item = value_type());
301 "#classboost_1_1circular__buffer_1477715e9d31d2cc5b02ad8ecf3c68c46">rset_capacity</a>(capacity_type new_capacity);
303 "#classboost_1_1circular__buffer_144ecd9ec5f54a2d61c7d132e445d3483">rresize</a>(size_type new_size, const_reference item = value_type());
304 circular_buffer<T, Alloc>& <a href=
305 "#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a>(const circular_buffer<T, Alloc>& cb);
307 "#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign</a>(size_type n, const_reference item);
309 "#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign</a>(capacity_type buffer_capacity, size_type n, const_reference item);
310 template <class InputIterator>
312 "#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign</a>(InputIterator first, InputIterator last);
313 template <class InputIterator>
315 "#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign</a>(capacity_type buffer_capacity, InputIterator first, InputIterator last);
317 "#classboost_1_1circular__buffer_1270ab7074c365663a6f18808024fd88b">swap</a>(circular_buffer<T, Alloc>& cb);
319 "#classboost_1_1circular__buffer_1aa35dd7ef8eb1d04508494d1835cc82e">push_back</a>(const_reference item = value_type());
321 "#classboost_1_1circular__buffer_10ef57e73c193682a649d8eb4a1096dce">push_front</a>(const_reference item = value_type());
322 void <a href="#classboost_1_1circular__buffer_1df0da00cb501bea75afbbfab9f546a07">pop_back</a>();
323 void <a href="#classboost_1_1circular__buffer_18ac972dc24ef7236faa1875de92b9dd8">pop_front</a>();
325 "#classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95">insert</a>(iterator pos, const_reference item = value_type());
327 "#classboost_1_1circular__buffer_1b2f197c99d47138db777f0a46783b140">insert</a>(iterator pos, size_type n, const_reference item);
328 template <class InputIterator>
330 "#classboost_1_1circular__buffer_1d00091d1d794cab3264b3674e99b33f6">insert</a>(iterator pos, InputIterator first, InputIterator last);
332 "#classboost_1_1circular__buffer_12c9332f457bf5bb3128463cf528c058c">rinsert</a>(iterator pos, const_reference item = value_type());
334 "#classboost_1_1circular__buffer_1a47a5358db1b7d7e4925c16db13d2fc5">rinsert</a>(iterator pos, size_type n, const_reference item);
335 template <class InputIterator>
337 "#classboost_1_1circular__buffer_1d6479cbc43a304bdbf04262f957fa323">rinsert</a>(iterator pos, InputIterator first, InputIterator last);
338 iterator <a href="#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase</a>(iterator pos);
340 "#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase</a>(iterator first, iterator last);
341 iterator <a href="#classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f">rerase</a>(iterator pos);
343 "#classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f">rerase</a>(iterator first, iterator last);
344 void <a href="#classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd">erase_begin</a>(size_type n);
345 void <a href="#classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7">erase_end</a>(size_type n);
346 void <a href="#classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e">clear</a>();
349 template <class T, class Alloc>
351 "#namespaceboost_1d35871e838359b5215e1cbb353663207">operator==</a>(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
352 template <class T, class Alloc>
354 "#namespaceboost_195b08213f201c2067d8acb024756329d">operator<</a>(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
355 template <class T, class Alloc>
357 "#namespaceboost_1f5717e2f6532581a6492ff1839b18f6d">operator!=</a>(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
358 template <class T, class Alloc>
360 "#namespaceboost_1f575d7a9741c2044424de50c966c12f3">operator></a>(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
361 template <class T, class Alloc>
363 "#namespaceboost_179abcbacd24b67f08185db54aec8600d">operator<=</a>(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
364 template <class T, class Alloc>
366 "#namespaceboost_11c31150380272af67deebef578c80b05">operator>=</a>(const circular_buffer<T, Alloc>& lhs, const circular_buffer<T, Alloc>& rhs);
367 template <class T, class Alloc>
369 "#namespaceboost_14aa8f6a2c9640f3f22e266f0fca85777">swap</a>(circular_buffer<T, Alloc>& lhs, circular_buffer<T, Alloc>& rhs);
378 <a name="rationale" id="rationale">Rationale</a>
381 The basic motivation behind the <code>circular_buffer</code> was to create a container which would work
382 seamlessly with STL. Additionally, the design of the <code>circular_buffer</code> was guided by the following
386 <li>Maximum <em>efficiency</em> for envisaged applications.
388 <li>Suitable for <em>general purpose</em> use.
390 <li>The behaviour of the buffer as <em>intuitive</em> as possible.
392 <li>Suitable for <em>specialization</em> by means of adaptors. (The <code><a href=
393 "space_optimized.html">circular_buffer_space_optimized</a></code> is such an example of the adaptor.)
395 <li>Easy to <em>debug</em>. (See <a href="#debug">Debug Support</a> for details.)
399 In order to achieve maximum efficiency, the <code>circular_buffer</code> stores its elements in a <em>contiguous
400 region of memory</em>, which then enables:
403 <li>Use of fixed memory and no implicit or unexpected memory allocation.
405 <li>Fast constant-time insertion and removal of elements from the front and back.
407 <li>Fast constant-time random access of elements.
409 <li>Suitability for real-time and performance critical applications.
413 Possible applications of the <code>circular_buffer</code> include:
416 <li>Storage of the most recently received samples, overwriting the oldest as new samples arrive.
418 <li>As an underlying container for a <i>bounded buffer</i> (see the <a href="#boundedbuffer">Bounded Buffer
421 <li>A kind of cache storing a specified number of last inserted elements.
423 <li>Efficient fixed capacity FIFO (First In, First Out) or LIFO (Last In, First Out) queue which removes the
424 oldest (inserted as first) elements when full.
428 The following paragraphs describe issues that had to be considered during the implementation of the
429 <code>circular_buffer</code>:
432 <a name="threadsafety" id="threadsafety">Thread-Safety</a>
435 The thread-safety of the <code>circular_buffer</code> is the same as the thread-safety of containers in most STL
436 implementations. This means the <code>circular_buffer</code> is <b>not</b> thread-safe. The thread-safety is
437 guarantied only in the sense that simultaneous accesses to <b>distinct</b> instances of the
438 <code>circular_buffer</code> are safe, and simultaneous read accesses to a shared <code>circular_buffer</code>
442 If multiple threads access a single <code>circular_buffer</code>, and at least one of the threads may potentially
443 write, then the user is responsible for ensuring mutual exclusion between the threads during the container
444 accesses. The mutual exclusion between the threads can be achieved by wrapping operations of the underlying
445 <code>circular_buffer</code> with a lock acquisition and release. (See the <a href="#boundedbuffer">Bounded
449 <a name="overwrite" id="overwrite">Overwrite Operation</a>
452 Overwrite operation occurs when an element is inserted into a full <code>circular_buffer</code> - the old element
453 is being overwritten by the new one. There was a discussion what exactly "overwriting of an element" means during
454 the formal review. It may be either a destruction of the original element and a consequent inplace construction
455 of a new element or it may be an assignment of a new element into an old one. The <code>circular_buffer</code>
456 implements <b>assignment</b> because it is more effective.
459 From the point of business logic of a stored element, the destruction/construction operation and assignment
460 usually mean the same. However, in very rare cases (if in any) they may differ. If there is a requirement for
461 elements to be destructed/constructed instead of being assigned, consider implementing a wrapper of the element
462 which would implement the assign operator, and store the wrappers instead. It is necessary to note that storing
463 such wrappers has a drawback. The destruction/construction will be invoked on every assignment of the wrapper -
464 not only when a wrapper is being overwritten (when the buffer is full) but also when the stored wrappers are
465 being shifted (e.g. as a result of insertion into the middle of container).
468 <a name="fullbuffer" id="fullbuffer">Writing to a Full Buffer</a>
471 There are several options how to cope with the case if a data source produces more data than can fit in the
475 <li>Inform the data source to wait until there is room in the buffer (e.g. by throwing an overflow exception).
477 <li>If the oldest data is the most important, ignore new data from the source until there is room in the buffer
480 <li>If the latest data is the most important, write over the oldest data.
482 <li>Let the producer to be responsible for checking the size of the buffer prior writing into it.
486 It is apparent that the <code>circular_buffer</code> implements the third option. But it may be less apparent it
487 <b>does not</b> implement any other option - especially the first two. One can get an impression that the
488 <code>circular_buffer</code> should implement first three options and offer a mechanism of choosing among them.
489 This impression is wrong. The <code>circular_buffer</code> was designed and optimized to be circular (which means
490 overwriting the oldest data when full). If such a controlling mechanism had been enabled, it would just
491 complicate the matters and the usage of the <code>circular_buffer</code> would be probably less straightforward.
494 Moreover, the first two options (and the fourth option as well) do not require the buffer to be circular at all.
495 If there is a need for the first or second option, consider implementing an adaptor of e.g.
496 <code>std::vector</code>. In this case the <code>circular_buffer</code> is not suitable for adapting, because, in
497 contrary to <code>std::vector</code>, it bears an overhead for its circular behaviour.
500 <a name="emptybuffer" id="emptybuffer">Reading/Removing from an Empty Buffer</a>
503 When reading or removing an element from an empty buffer, the buffer should be able to notify the data consumer
504 (e.g. by throwing underflow exception) that there are no elements stored in it. The <code>circular_buffer</code>
505 does not implement such a behaviour for two reasons:
508 <li>It would introduce performance overhead.
510 <li>No other <code>std</code> container implements it this way.
514 It is considered to be a bug to read or remove an element (e.g. by calling <code>front()</code> or
515 <code>pop_back()</code>) from an empty <code>std</code> container and from an empty <code>circular_buffer</code>
516 as well. The data consumer has to test if the container is not empty before reading/removing from it. However,
517 when reading from the <code>circular_buffer</code>, there is an option to rely on the <code>at()</code> method
518 which throws an exception when the index is out of range.
521 <a name="iteratorinvalidation" id="iteratorinvalidation">Iterator Invalidation</a>
524 An iterator is usually considered to be invalidated if an element, the iterator pointed to, had been removed or
525 overwritten by an another element. This definition is enforced by the <a href="#debug">Debug Support</a> and is
526 documented for every method. However, some applications utilizing <code>circular_buffer</code> may require less
527 strict definition: an iterator is invalid only if it points to an uninitialized memory. Consider following
531 #define BOOST_CB_DISABLE_DEBUG // The Debug Support has to be disabled, otherwise the code produces a runtime error.
533 #include <boost/circular_buffer.hpp>
534 #include <assert.h>
536 int main(int /*argc*/, char* /*argv*/[]) {
538 boost::circular_buffer<int> cb(3);
544 boost::circular_buffer<int>::iterator it = cb.begin();
550 assert(*it == 4); // The iterator still points to the initialized memory.
556 The iterator does not point to the original element any more (and is considered to be invalid from the "strict"
557 point of view) but it still points to the same <em>valid</em> place in the memory. This "soft" definition of
558 iterator invalidation is supported by the <code>circular_buffer</code> but should be considered as an
559 implementation detail rather than a full-fledged feature. The rules when the iterator is still valid can be
560 inferred from the code in <code><a href=
561 "../test/soft_iterator_invalidation.cpp">soft_iterator_invalidation.cpp</a></code>.
564 <a name="caveats" id="caveats">Caveats</a>
567 The <code>circular_buffer</code> should not be used for storing pointers to dynamically allocated objects. When a
568 <code>circular_buffer</code> becomes full, further insertion will overwrite the stored pointers - resulting in a
569 <b>memory leak</b>. One recommend alternative is the use of smart pointers <a href="#note1">[1]</a>. (Any
570 container of <code>std::auto_ptr</code> is considered particularly hazardous. <a href="#note2">[2]</a> )
573 While internals of a <code>circular_buffer</code> are circular, iterators are <b>not</b>. Iterators of a
574 <code>circular_buffer</code> are only valid for the range <code>[begin(), end()]</code>. E.g. iterators
575 <code>(begin() - 1)</code> and <code>(end() + 1)</code> are invalid.
578 <a name="debug" id="debug">Debug Support</a>
581 In order to help a programmer to avoid and find common bugs, the <code>circular_buffer</code> contains a kind of
585 The <code>circular_buffer</code> maintains a list of valid iterators. As soon as any element gets destroyed all
586 iterators pointing to this element are removed from this list and explicitly invalidated (an invalidation flag is
587 set). The debug support also consists of many assertions (<a href=
588 "../../utility/assert.html"><code>BOOST_ASSERT</code></a> macros) which ensure the <code>circular_buffer</code>
589 and its iterators are used in the correct manner at runtime. In case an invalid iterator is used the assertion
590 will report an error. The connection of explicit iterator invalidation and assertions makes a very robust debug
591 technique which catches most of the errors.
594 Moreover, the uninitialized memory allocated by <code>circular_buffer</code> is filled with the value
595 <code>0xcc</code> in the debug mode. This can help the programmer when debugging the code to recognize the
596 initialized memory from the uninitialized. For details refer the source code.
599 The debug support is enabled only in the debug mode (when the <code>NDEBUG</code> is not defined). It can also be
600 explicitly disabled (only for <code>circular_buffer</code>) by defining <code>BOOST_CB_DISABLE_DEBUG</code>
604 <a name="intreprocess" id="interprocess">Compatibility with Interprocess library</a>
607 The <code>circular_buffer</code> is compatible with the <a href="../../../doc/html/interprocess.html">Boost
608 Interprocess</a> library used for interprocess communication. Considering that the <code>circular_buffer</code>'s
609 debug support relies on 'raw' pointers - which is not permited by the Interprocess library - the code has to
610 compiled with <code>-DBOOST_CB_DISABLE_DEBUG</code> or <code>-DNDEBUG</code> (which disables the
611 <a href="#debug">Debug Support</a>). Not doing that will cause the compilation to fail.
614 <a name="examples" id="examples">More Examples</a>
617 The following example includes various usage of the <code>circular_buffer</code>.
620 #include <boost/circular_buffer.hpp>
621 #include <numeric>
622 #include <assert.h>
624 int main(int /*argc*/, char* /*argv*/[])
626 // create a circular buffer of capacity 3
627 boost::circular_buffer<int> cb(3);
629 // insert some elements into the circular buffer
637 assert(cb.size() == 2);
638 assert(cb.capacity() == 3);
640 // insert some other elements
645 int sum = std::accumulate(cb.begin(), cb.end(), 0);
651 assert(*cb.begin() == 2);
652 assert(cb.front() == 2);
653 assert(cb.back() == 4);
656 assert(cb.size() == 3);
657 assert(cb.capacity() == 3);
663 The <code>circular_buffer</code> has a capacity of three <code>int</code>. Therefore, the size of the buffer will
664 not exceed three. The <code><a href="http://www.sgi.com/tech/stl/accumulate.html">std::accumulate</a></code>
665 algorithm evaluates the sum of the stored elements. The semantics of the <code>circular_buffer</code> can be
666 inferred from the assertions.
669 <a name="boundedbuffer" id="boundedbuffer">Bounded Buffer Example</a>
672 The bounded buffer is normally used in a producer-consumer mode when producer threads produce items and store
673 them in the container and consumer threads remove these items and process them. The bounded buffer has to
674 guarantee that producers do not insert items into the container when the container is full, that consumers do not
675 try to remove items when the container is empty, and that each produced item is consumed by exactly one consumer.
678 The example below shows how the <code>circular_buffer</code> can be utilized as an underlying container of the
682 #include <boost/circular_buffer.hpp>
683 #include <boost/thread/mutex.hpp>
684 #include <boost/thread/condition.hpp>
685 #include <boost/thread/thread.hpp>
686 #include <boost/call_traits.hpp>
687 #include <boost/progress.hpp>
688 #include <boost/bind.hpp>
690 template <class T>
691 class bounded_buffer {
694 typedef boost::circular_buffer<T> container_type;
695 typedef typename container_type::size_type size_type;
696 typedef typename container_type::value_type value_type;
697 typedef typename boost::call_traits<value_type>::param_type param_type;
699 explicit bounded_buffer(size_type capacity) : m_unread(0), m_container(capacity) {}
701 void push_front(boost::call_traits<value_type>::param_type item) {
702 // param_type represents the "best" way to pass a parameter of type value_type to a method
704 boost::mutex::scoped_lock lock(m_mutex);
705 m_not_full.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_full, this));
706 m_container.push_front(item);
709 m_not_empty.notify_one();
712 void pop_back(value_type* pItem) {
713 boost::mutex::scoped_lock lock(m_mutex);
714 m_not_empty.wait(lock, boost::bind(&bounded_buffer<value_type>::is_not_empty, this));
715 *pItem = m_container[--m_unread];
717 m_not_full.notify_one();
721 bounded_buffer(const bounded_buffer&); // Disabled copy constructor
722 bounded_buffer& operator = (const bounded_buffer&); // Disabled assign operator
724 bool is_not_empty() const { return m_unread > 0; }
725 bool is_not_full() const { return m_unread < m_container.capacity(); }
728 container_type m_container;
729 boost::mutex m_mutex;
730 boost::condition m_not_empty;
731 boost::condition m_not_full;
735 The <code>bounded_buffer</code> relies on <a href="../../thread/doc/">Boost Threads</a> and <a href=
736 "../../bind/bind.html">Boost Bind</a> libraries and <a href="../../utility/call_traits.htm">Boost call_traits</a>
740 The <code>push_front()</code> method is called by the producer thread in order to insert a new item into the
741 buffer. The method locks the mutex and waits until there is a space for the new item. (The mutex is unlocked
742 during the waiting stage and has to be regained when the condition is met.) If there is a space in the buffer
743 available, the execution continues and the method inserts the item at the end of the
744 <code>circular_buffer</code>. Then it increments the number of unread items and unlocks the mutex (in case an
745 exception is thrown before the mutex is unlocked, the mutex is unlocked automatically by the destructor of the
746 <code>scoped_lock</code>). At last the method notifies one of the consumer threads waiting for a new item to be
747 inserted into the buffer.
750 The <code>pop_back()</code> method is called by the consumer thread in order to read the next item from the
751 buffer. The method locks the mutex and waits until there is an unread item in the buffer. If there is at least
752 one unread item, the method decrements the number of unread items and reads the next item from the
753 <code>circular_buffer</code>. Then it unlocks the mutex and notifies one of the producer threads waiting for the
754 buffer to free a space for the next item.
757 The <code>pop_back()</code> method does not remove the item but the item is left in the
758 <code>circular_buffer</code> which then replaces it with a new one (inserted by a producer) when the
759 <code>circular_buffer</code> is full. This technique is more effective than removing the item explicitly by
760 calling the <code>pop_back()</code> method of the <code>circular_buffer</code>. This claim is based on the
761 assumption that an assignment (replacement) of a new item into an old one is more effective than a destruction
762 (removal) of an old item and a consequent inplace construction (insertion) of a new item.
765 For comparison of bounded buffers based on different containers compile and run <a href=
766 "../test/bounded_buffer_comparison.cpp">bounded_buffer_comparison.cpp</a>. The test should reveal the bounded
767 buffer based on the <code>circular_buffer</code> is most effective closely followed by the
768 <code>std::deque</code> based bounded buffer. (In reality the result may differ sometimes because the test is
769 always affected by external factors such as immediate CPU load.)
772 <a name="header" id="header">Header Files</a>
775 The <code>circular_buffer</code> is defined in the file <code><a href=
776 "../../../boost/circular_buffer.hpp">boost/circular_buffer.hpp</a></code>. There is also a forward declaration
777 for the <code>circular_buffer</code> in the header file <code><a href=
778 "../../../boost/circular_buffer_fwd.hpp">boost/circular_buffer_fwd.hpp</a></code>.
781 <a name="model" id="model">Modelled Concepts</a>
784 <a href="http://www.sgi.com/tech/stl/RandomAccessContainer.html">Random Access Container</a>, <a href=
785 "http://www.sgi.com/tech/stl/FrontInsertionSequence.html">Front Insertion Sequence</a> and <a href=
786 "http://www.sgi.com/tech/stl/BackInsertionSequence.html">Back Insertion Sequence</a>.
789 <a name="parameters" id="parameters">Template Parameters</a>
791 <div id="srcdoc_params">
792 <table id="table_template_params" border="1" cellpadding="3">
806 <a id="templateparam_T" name="templateparam_T"><code>T</code></a>
809 The type of the elements stored in the <code>circular_buffer</code>.
812 <b>Type Requirements:</b>
815 The <code>T</code> has to be <a href="http://www.sgi.com/tech/stl/Assignable.html">SGIAssignable</a>
816 (SGI STL defined combination of <a href="../../utility/Assignable.html">Assignable</a> and <a href=
817 "../../utility/CopyConstructible.html">CopyConstructible</a>). Moreover <code>T</code> has to be
818 <a href="http://www.sgi.com/tech/stl/DefaultConstructible.html">DefaultConstructible</a> if supplied as
819 a default parameter when invoking some of the <code>circular_buffer</code>'s methods e.g.
820 <code>insert(iterator pos, const value_type& item = value_type())</code>. And <a href=
821 "http://www.sgi.com/tech/stl/EqualityComparable.html">EqualityComparable</a> and/or <a href=
822 "../../utility/LessThanComparable.html">LessThanComparable</a> if the <code>circular_buffer</code> will
823 be compared with another container.
833 <a id="templateparam_Alloc" name="templateparam_Alloc"><code>Alloc</code></a>
836 The allocator type used for all internal memory management.
839 <b>Type Requirements:</b>
842 The <code>Alloc</code> has to meet the allocator requirements imposed by STL.
847 <code>std::allocator<T></code>
853 <a name="types" id="types">Public Types</a>
855 <div id="srcdoc_types">
856 <table id="table_public_types" border="1" cellpadding="3">
867 <a id="classboost_1_1circular__buffer_1cbdd7ca87e147c08cd2be267eefd6540" name=
868 "classboost_1_1circular__buffer_1cbdd7ca87e147c08cd2be267eefd6540"><code>value_type</code></a>
871 The type of elements stored in the <code>circular_buffer</code>.
876 <a id="classboost_1_1circular__buffer_14ff917f8a6131ec18e91606727592a9c" name=
877 "classboost_1_1circular__buffer_14ff917f8a6131ec18e91606727592a9c"><code>pointer</code></a>
880 A pointer to an element.
885 <a id="classboost_1_1circular__buffer_190f7c6bcb624ad507de546366f49028a" name=
886 "classboost_1_1circular__buffer_190f7c6bcb624ad507de546366f49028a"><code>const_pointer</code></a>
889 A const pointer to the element.
894 <a id="classboost_1_1circular__buffer_1f38a9bc64d84757c661c2542ff9a7f65" name=
895 "classboost_1_1circular__buffer_1f38a9bc64d84757c661c2542ff9a7f65"><code>reference</code></a>
898 A reference to an element.
903 <a id="classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910" name=
904 "classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910"><code>const_reference</code></a>
907 A const reference to an element.
912 <a id="classboost_1_1circular__buffer_15313e723fa85d73db5826f8b722aa2a9" name=
913 "classboost_1_1circular__buffer_15313e723fa85d73db5826f8b722aa2a9"><code>difference_type</code></a>
916 The distance type. (A signed integral type used to represent the distance between two iterators.)
921 <a id="classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00" name=
922 "classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00"><code>size_type</code></a>
925 The size type. (An unsigned integral type that can represent any non-negative value of the container's
931 <a id="classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7" name=
932 "classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7"><code>allocator_type</code></a>
935 The type of an allocator used in the <code>circular_buffer</code>.
940 <a id="classboost_1_1circular__buffer_15cab6d46f03c40d1e52d41843319ddb9" name=
941 "classboost_1_1circular__buffer_15cab6d46f03c40d1e52d41843319ddb9"><code>const_iterator</code></a>
944 A const (random access) iterator used to iterate through the <code>circular_buffer</code>.
949 <a id="classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532" name=
950 "classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532"><code>iterator</code></a>
953 A (random access) iterator used to iterate through the <code>circular_buffer</code>.
958 <a id="classboost_1_1circular__buffer_1c7317701b511bc5f7a663b06b53e2b73" name=
959 "classboost_1_1circular__buffer_1c7317701b511bc5f7a663b06b53e2b73"><code>const_reverse_iterator</code></a>
962 A const iterator used to iterate backwards through a <code>circular_buffer</code>.
967 <a id="classboost_1_1circular__buffer_1002fb890dded89e75dfeb6f021fb58a5" name=
968 "classboost_1_1circular__buffer_1002fb890dded89e75dfeb6f021fb58a5"><code>reverse_iterator</code></a>
971 An iterator used to iterate backwards through a <code>circular_buffer</code>.
976 <a id="classboost_1_1circular__buffer_126d279f91fef717e25459a0817ff242f" name=
977 "classboost_1_1circular__buffer_126d279f91fef717e25459a0817ff242f"><code>array_range</code></a>
980 An array range. (A typedef for the <a href=
981 "http://www.sgi.com/tech/stl/pair.html"><code>std::pair</code></a> where its first element is a pointer to
982 a beginning of an array and its second element represents a size of the array.)
987 <a id="classboost_1_1circular__buffer_11885d7f475b7e7a74c95b2448d243025" name=
988 "classboost_1_1circular__buffer_11885d7f475b7e7a74c95b2448d243025"><code>const_array_range</code></a>
991 A range of a const array. (A typedef for the <a href=
992 "http://www.sgi.com/tech/stl/pair.html"><code>std::pair</code></a> where its first element is a pointer to
993 a beginning of a const array and its second element represents a size of the const array.)
998 <a id="classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595" name=
999 "classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595"><code>capacity_type</code></a>
1002 The capacity type. (Same as <code>size_type</code> - defined for consistency with the <a href=
1003 "space_optimized.html"><code>circular_buffer_space_optimized</code></a>.)
1009 <a name="constructors" id="constructors">Constructors and Destructor</a>
1011 <div id="srcdoc_constructors">
1012 <table id="table_constructors" border="1" cellpadding="3">
1015 <a id="classboost_1_1circular__buffer_1e53e744d2f94a2bcbfcdb219a9d93300" name=
1016 "classboost_1_1circular__buffer_1e53e744d2f94a2bcbfcdb219a9d93300"></a><code><b>explicit
1017 circular_buffer(const <a href=
1018 "#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>& alloc =
1019 allocator_type());</b></code><br>
1021 Create an empty <code>circular_buffer</code> with zero capacity.
1027 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> == 0
1028 && <a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
1034 <b>Parameter(s):</b>
1052 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
1069 Since Boost version 1.36 the behaviour of this constructor has changed. Now the constructor does not
1070 allocate any memory and both capacity and size are set to zero. Also note when inserting an element
1071 into a <code>circular_buffer</code> with zero capacity (e.g. by <code><a href=
1072 "#classboost_1_1circular__buffer_1aa35dd7ef8eb1d04508494d1835cc82e">push_back(const_reference)</a></code>
1073 or <code><a href="#classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95">insert(iterator,
1074 value_type)</a></code>) nothing will be inserted and the size (as well as capacity) remains zero.
1082 You can explicitly set the capacity by calling the <code><a href=
1083 "#classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f">set_capacity(capacity_type)</a></code>
1084 method or you can use the other constructor with the capacity specified.
1093 "#classboost_1_1circular__buffer_18f1606a26fead923c2cbe068a74e28b6">circular_buffer(capacity_type,
1094 const allocator_type& alloc)</a></code>, <code><a href=
1095 "#classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f">set_capacity(capacity_type)</a></code>
1102 <a id="classboost_1_1circular__buffer_18f1606a26fead923c2cbe068a74e28b6" name=
1103 "classboost_1_1circular__buffer_18f1606a26fead923c2cbe068a74e28b6"></a><code><b>explicit
1104 circular_buffer(<a href=
1105 "#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
1106 const <a href="#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>&
1107 alloc = allocator_type());</b></code><br>
1109 Create an empty <code>circular_buffer</code> with the specified capacity.
1115 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
1116 buffer_capacity && <a href=
1117 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == 0</code>
1122 <b>Parameter(s):</b>
1127 <code>buffer_capacity</code>
1130 The maximum number of elements which can be stored in the <code>circular_buffer</code>.
1150 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
1166 <a id="classboost_1_1circular__buffer_1fdace8f110d5b7a17c02020757f06fe8" name=
1167 "classboost_1_1circular__buffer_1fdace8f110d5b7a17c02020757f06fe8"></a><code><b>circular_buffer(<a href=
1168 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
1169 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item, const
1170 <a href="#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>& alloc =
1171 allocator_type());</b></code><br>
1173 Create a full <code>circular_buffer</code> with the specified capacity and filled with <code>n</code>
1174 copies of <code>item</code>.
1180 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> == n
1181 && <a href="#classboost_1_1circular__buffer_1fd0eef8ba91210d1575404b7e3e8207a">full()</a>
1182 && (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] ==
1188 <b>Parameter(s):</b>
1196 The number of elements the created <code>circular_buffer</code> will be filled with.
1206 The element the created <code>circular_buffer</code> will be filled with.
1226 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
1230 Whatever <code>T::T(const T&)</code> throws.
1238 Linear (in the <code>n</code>).
1245 <a id="classboost_1_1circular__buffer_104dc644486d835b56aa479ec48b52230" name=
1246 "classboost_1_1circular__buffer_104dc644486d835b56aa479ec48b52230"></a><code><b>circular_buffer(<a href=
1247 "#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
1248 <a href="#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
1249 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item, const
1250 <a href="#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>& alloc =
1251 allocator_type());</b></code><br>
1253 Create a <code>circular_buffer</code> with the specified capacity and filled with <code>n</code> copies of
1257 <b>Precondition:</b>
1260 <code>buffer_capacity >= n</code>
1268 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
1269 buffer_capacity && <a href=
1270 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n &&
1271 (*this)[0] == item && (*this)[1] == item && ... && (*this)[n - 1] ==
1277 <b>Parameter(s):</b>
1282 <code>buffer_capacity</code>
1285 The capacity of the created <code>circular_buffer</code>.
1295 The number of elements the created <code>circular_buffer</code> will be filled with.
1305 The element the created <code>circular_buffer</code> will be filled with.
1325 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
1329 Whatever <code>T::T(const T&)</code> throws.
1337 Linear (in the <code>n</code>).
1344 <a id="classboost_1_1circular__buffer_1e515d8a951eeb18b8cc930300e7e13bd" name=
1345 "classboost_1_1circular__buffer_1e515d8a951eeb18b8cc930300e7e13bd"></a><code><b>circular_buffer(const
1346 circular_buffer<T,Alloc>& cb);</b></code><br>
1348 The copy constructor.
1350 Creates a copy of the specified <code>circular_buffer</code>.
1357 <code>*this == cb</code>
1362 <b>Parameter(s):</b>
1370 The <code>circular_buffer</code> to be copied.
1380 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
1384 Whatever <code>T::T(const T&)</code> throws.
1392 Linear (in the size of <code>cb</code>).
1399 <a id="classboost_1_1circular__buffer_1744ec06b06a5a723386b645a29cb8ed2" name=
1400 "classboost_1_1circular__buffer_1744ec06b06a5a723386b645a29cb8ed2"></a> <code><b>template <class
1401 InputIterator><br>
1402 circular_buffer(InputIterator first, InputIterator last, const <a href=
1403 "#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>& alloc =
1404 allocator_type());</b></code><br>
1406 Create a full <code>circular_buffer</code> filled with a copy of the range.
1409 <b>Precondition:</b>
1412 Valid range <code>[first, last)</code>.<br>
1413 <code>first</code> and <code>last</code> have to meet the requirements of <a href=
1414 "http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
1422 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
1423 std::distance(first, last) && <a href=
1424 "#classboost_1_1circular__buffer_1fd0eef8ba91210d1575404b7e3e8207a">full()</a> && (*this)[0]==
1425 *first && (*this)[1] == *(first + 1) && ... && (*this)[std::distance(first,
1426 last) - 1] == *(last - 1)</code>
1431 <b>Parameter(s):</b>
1439 The beginning of the range to be copied.
1449 The end of the range to be copied.
1469 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
1473 Whatever <code>T::T(const T&)</code> throws.
1481 Linear (in the <code>std::distance(first, last)</code>).
1488 <a id="classboost_1_1circular__buffer_1a851f75f4a85b1a2b1a241904d21503f" name=
1489 "classboost_1_1circular__buffer_1a851f75f4a85b1a2b1a241904d21503f"></a> <code><b>template <class
1490 InputIterator><br>
1491 circular_buffer(<a href=
1492 "#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
1493 InputIterator first, InputIterator last, const <a href=
1494 "#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>& alloc =
1495 allocator_type());</b></code><br>
1497 Create a <code>circular_buffer</code> with the specified capacity and filled with a copy of the range.
1500 <b>Precondition:</b>
1503 Valid range <code>[first, last)</code>.<br>
1504 <code>first</code> and <code>last</code> have to meet the requirements of <a href=
1505 "http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
1513 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
1514 buffer_capacity && <a href=
1515 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> <=
1516 std::distance(first, last) && (*this)[0]== *(last - buffer_capacity) && (*this)[1] ==
1517 *(last - buffer_capacity + 1) && ... && (*this)[buffer_capacity - 1] == *(last -
1520 If the number of items to be copied from the range <code>[first, last)</code> is greater than the
1521 specified <code>buffer_capacity</code> then only elements from the range <code>[last - buffer_capacity,
1522 last)</code> will be copied.
1527 <b>Parameter(s):</b>
1532 <code>buffer_capacity</code>
1535 The capacity of the created <code>circular_buffer</code>.
1545 The beginning of the range to be copied.
1555 The end of the range to be copied.
1575 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
1579 Whatever <code>T::T(const T&)</code> throws.
1587 Linear (in <code>std::distance(first, last)</code>; in <code>min[capacity, std::distance(first,
1588 last)]</code> if the <code>InputIterator</code> is a <a href=
1589 "http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
1596 <a id="classboost_1_1circular__buffer_164250ffbbbdbc62b99e8301fc195b80c" name=
1597 "classboost_1_1circular__buffer_164250ffbbbdbc62b99e8301fc195b80c"></a><code><b>~circular_buffer();</b></code><br>
1602 Destroys the <code>circular_buffer</code>.
1614 <b>Iterator Invalidation:</b>
1617 Invalidates all iterators pointing to the <code>circular_buffer</code> (including iterators equal to
1618 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
1626 Constant (in the size of the <code>circular_buffer</code>) for scalar types; linear for other types.
1634 <code><a href="#classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e">clear()</a></code>
1642 <a name="methods" id="methods">Public Member Functions</a>
1644 <div id="srcdoc_methods">
1645 <table id="table_methods" border="1" cellpadding="3">
1648 <a id="classboost_1_1circular__buffer_1a20b7d0e7a4da0af13286df9f53d660c" name=
1649 "classboost_1_1circular__buffer_1a20b7d0e7a4da0af13286df9f53d660c"></a><code><b><a href=
1650 "#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a> get_allocator()
1651 const;</b></code><br>
1672 <b>Exception Safety:</b>
1680 <b>Iterator Invalidation:</b>
1683 Does not invalidate any iterators.
1691 Constant (in the size of the <code>circular_buffer</code>).
1700 "#classboost_1_1circular__buffer_1af7758a36ac2f84a3024b50b4fc7e098">get_allocator()</a></code> for
1701 obtaining an allocator reference.
1708 <a id="classboost_1_1circular__buffer_1af7758a36ac2f84a3024b50b4fc7e098" name=
1709 "classboost_1_1circular__buffer_1af7758a36ac2f84a3024b50b4fc7e098"></a><code><b><a href=
1710 "#classboost_1_1circular__buffer_14e07c6ddfe89debe384e59bed06e7cb7">allocator_type</a>&
1711 get_allocator();</b></code><br>
1713 Get the allocator reference.
1719 A reference to the allocator.
1732 <b>Exception Safety:</b>
1740 <b>Iterator Invalidation:</b>
1743 Does not invalidate any iterators.
1751 Constant (in the size of the <code>circular_buffer</code>).
1759 This method was added in order to optimize obtaining of the allocator with a state, although use of
1760 stateful allocators in STL is discouraged.
1768 <code><a href="#classboost_1_1circular__buffer_1a20b7d0e7a4da0af13286df9f53d660c">get_allocator()
1776 <a id="classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0" name=
1777 "classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0"></a><code><b><a href=
1778 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> begin();</b></code><br>
1780 Get the iterator pointing to the beginning of the <code>circular_buffer</code>.
1786 A random access iterator pointing to the first element of the <code>circular_buffer</code>. If the
1787 <code>circular_buffer</code> is empty it returns an iterator equal to the one returned by
1788 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>.
1801 <b>Exception Safety:</b>
1809 <b>Iterator Invalidation:</b>
1812 Does not invalidate any iterators.
1820 Constant (in the size of the <code>circular_buffer</code>).
1828 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>,
1829 <code><a href="#classboost_1_1circular__buffer_1db3d6b10b6763549f54d2627228fa7aa">rbegin()</a></code>,
1830 <code><a href="#classboost_1_1circular__buffer_1cff9236a50107188b8942847a4dc2697">rend()</a></code>
1837 <a id="classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1" name=
1838 "classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1"></a><code><b><a href=
1839 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> end();</b></code><br>
1841 Get the iterator pointing to the end of the <code>circular_buffer</code>.
1847 A random access iterator pointing to the element "one behind" the last element of the
1848 <code>circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal
1849 to the one returned by <code><a href=
1850 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code>.
1863 <b>Exception Safety:</b>
1871 <b>Iterator Invalidation:</b>
1874 Does not invalidate any iterators.
1882 Constant (in the size of the <code>circular_buffer</code>).
1890 <code><a href="#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code>,
1891 <code><a href="#classboost_1_1circular__buffer_1db3d6b10b6763549f54d2627228fa7aa">rbegin()</a></code>,
1892 <code><a href="#classboost_1_1circular__buffer_1cff9236a50107188b8942847a4dc2697">rend()</a></code>
1899 <a id="classboost_1_1circular__buffer_10640d3d41c13b6089b6f169224cf1038" name=
1900 "classboost_1_1circular__buffer_10640d3d41c13b6089b6f169224cf1038"></a><code><b><a href=
1901 "#classboost_1_1circular__buffer_15cab6d46f03c40d1e52d41843319ddb9">const_iterator</a> begin()
1902 const;</b></code><br>
1904 Get the const iterator pointing to the beginning of the <code>circular_buffer</code>.
1910 A const random access iterator pointing to the first element of the <code>circular_buffer</code>. If
1911 the <code>circular_buffer</code> is empty it returns an iterator equal to the one returned by
1912 <code><a href="#classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac">end()
1926 <b>Exception Safety:</b>
1934 <b>Iterator Invalidation:</b>
1937 Does not invalidate any iterators.
1945 Constant (in the size of the <code>circular_buffer</code>).
1953 <code><a href="#classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac">end()
1954 const</a></code>, <code><a href=
1955 "#classboost_1_1circular__buffer_1765d91bf48341907418433a1e3aab026">rbegin() const</a></code>,
1956 <code><a href="#classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3">rend()
1964 <a id="classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac" name=
1965 "classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac"></a><code><b><a href=
1966 "#classboost_1_1circular__buffer_15cab6d46f03c40d1e52d41843319ddb9">const_iterator</a> end()
1967 const;</b></code><br>
1969 Get the const iterator pointing to the end of the <code>circular_buffer</code>.
1975 A const random access iterator pointing to the element "one behind" the last element of the
1976 <code>circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal
1977 to the one returned by <code><a href=
1978 "#classboost_1_1circular__buffer_10640d3d41c13b6089b6f169224cf1038">begin() const</a></code> const.
1991 <b>Exception Safety:</b>
1999 <b>Iterator Invalidation:</b>
2002 Does not invalidate any iterators.
2010 Constant (in the size of the <code>circular_buffer</code>).
2018 <code><a href="#classboost_1_1circular__buffer_10640d3d41c13b6089b6f169224cf1038">begin()
2019 const</a></code>, <code><a href=
2020 "#classboost_1_1circular__buffer_1765d91bf48341907418433a1e3aab026">rbegin() const</a></code>,
2021 <code><a href="#classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3">rend()
2029 <a id="classboost_1_1circular__buffer_1db3d6b10b6763549f54d2627228fa7aa" name=
2030 "classboost_1_1circular__buffer_1db3d6b10b6763549f54d2627228fa7aa"></a><code><b><a href=
2031 "#classboost_1_1circular__buffer_1002fb890dded89e75dfeb6f021fb58a5">reverse_iterator</a>
2032 rbegin();</b></code><br>
2034 Get the iterator pointing to the beginning of the "reversed" <code>circular_buffer</code>.
2040 A reverse random access iterator pointing to the last element of the <code>circular_buffer</code>. If
2041 the <code>circular_buffer</code> is empty it returns an iterator equal to the one returned by
2042 <code><a href="#classboost_1_1circular__buffer_1cff9236a50107188b8942847a4dc2697">rend()</a></code>.
2055 <b>Exception Safety:</b>
2063 <b>Iterator Invalidation:</b>
2066 Does not invalidate any iterators.
2074 Constant (in the size of the <code>circular_buffer</code>).
2082 <code><a href="#classboost_1_1circular__buffer_1cff9236a50107188b8942847a4dc2697">rend()</a></code>,
2083 <code><a href="#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code>,
2084 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>
2091 <a id="classboost_1_1circular__buffer_1cff9236a50107188b8942847a4dc2697" name=
2092 "classboost_1_1circular__buffer_1cff9236a50107188b8942847a4dc2697"></a><code><b><a href=
2093 "#classboost_1_1circular__buffer_1002fb890dded89e75dfeb6f021fb58a5">reverse_iterator</a>
2094 rend();</b></code><br>
2096 Get the iterator pointing to the end of the "reversed" <code>circular_buffer</code>.
2102 A reverse random access iterator pointing to the element "one before" the first element of the
2103 <code>circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal
2104 to the one returned by <code><a href=
2105 "#classboost_1_1circular__buffer_1db3d6b10b6763549f54d2627228fa7aa">rbegin()</a></code>.
2118 <b>Exception Safety:</b>
2126 <b>Iterator Invalidation:</b>
2129 Does not invalidate any iterators.
2137 Constant (in the size of the <code>circular_buffer</code>).
2145 <code><a href="#classboost_1_1circular__buffer_1db3d6b10b6763549f54d2627228fa7aa">rbegin()</a></code>,
2146 <code><a href="#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code>,
2147 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>
2154 <a id="classboost_1_1circular__buffer_1765d91bf48341907418433a1e3aab026" name=
2155 "classboost_1_1circular__buffer_1765d91bf48341907418433a1e3aab026"></a><code><b><a href=
2156 "#classboost_1_1circular__buffer_1c7317701b511bc5f7a663b06b53e2b73">const_reverse_iterator</a> rbegin()
2157 const;</b></code><br>
2159 Get the const iterator pointing to the beginning of the "reversed" <code>circular_buffer</code>.
2165 A const reverse random access iterator pointing to the last element of the
2166 <code>circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal
2167 to the one returned by <code><a href=
2168 "#classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3">rend() const</a></code>.
2181 <b>Exception Safety:</b>
2189 <b>Iterator Invalidation:</b>
2192 Does not invalidate any iterators.
2200 Constant (in the size of the <code>circular_buffer</code>).
2208 <code><a href="#classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3">rend()
2209 const</a></code>, <code><a href=
2210 "#classboost_1_1circular__buffer_10640d3d41c13b6089b6f169224cf1038">begin() const</a></code>,
2211 <code><a href="#classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac">end()
2219 <a id="classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3" name=
2220 "classboost_1_1circular__buffer_108dbf538b00a14daf5582ece80746fc3"></a><code><b><a href=
2221 "#classboost_1_1circular__buffer_1c7317701b511bc5f7a663b06b53e2b73">const_reverse_iterator</a> rend()
2222 const;</b></code><br>
2224 Get the const iterator pointing to the end of the "reversed" <code>circular_buffer</code>.
2230 A const reverse random access iterator pointing to the element "one before" the first element of the
2231 <code>circular_buffer</code>. If the <code>circular_buffer</code> is empty it returns an iterator equal
2232 to the one returned by <code><a href=
2233 "#classboost_1_1circular__buffer_1765d91bf48341907418433a1e3aab026">rbegin() const</a></code>.
2246 <b>Exception Safety:</b>
2254 <b>Iterator Invalidation:</b>
2257 Does not invalidate any iterators.
2265 Constant (in the size of the <code>circular_buffer</code>).
2273 <code><a href="#classboost_1_1circular__buffer_1765d91bf48341907418433a1e3aab026">rbegin()
2274 const</a></code>, <code><a href=
2275 "#classboost_1_1circular__buffer_10640d3d41c13b6089b6f169224cf1038">begin() const</a></code>,
2276 <code><a href="#classboost_1_1circular__buffer_17890810d07bc595cfb87f9c47cb075ac">end()
2284 <a id="classboost_1_1circular__buffer_1d219f0d3203fb43b964a8cf63f1865cd" name=
2285 "classboost_1_1circular__buffer_1d219f0d3203fb43b964a8cf63f1865cd"></a><code><b><a href=
2286 "#classboost_1_1circular__buffer_1f38a9bc64d84757c661c2542ff9a7f65">reference</a> operator[](<a href=
2287 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> index);</b></code><br>
2289 Get the element at the <code>index</code> position.
2292 <b>Precondition:</b>
2295 <code>0 <= index && index < <a href=
2296 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>
2301 <b>Parameter(s):</b>
2309 The position of the element.
2319 A reference to the element at the <code>index</code> position.
2332 <b>Exception Safety:</b>
2340 <b>Iterator Invalidation:</b>
2343 Does not invalidate any iterators.
2351 Constant (in the size of the <code>circular_buffer</code>).
2359 <code><a href="#classboost_1_1circular__buffer_1cd84838cb4fffb6c113fd0297e502edc">at()</a></code>
2366 <a id="classboost_1_1circular__buffer_1eb0a7fe7f8a56a4dc4c933b93adfcef4" name=
2367 "classboost_1_1circular__buffer_1eb0a7fe7f8a56a4dc4c933b93adfcef4"></a><code><b><a href=
2368 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> operator[](<a href=
2369 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> index)
2370 const;</b></code><br>
2372 Get the element at the <code>index</code> position.
2375 <b>Precondition:</b>
2378 <code>0 <= index && index < <a href=
2379 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>
2384 <b>Parameter(s):</b>
2392 The position of the element.
2402 A const reference to the element at the <code>index</code> position.
2415 <b>Exception Safety:</b>
2423 <b>Iterator Invalidation:</b>
2426 Does not invalidate any iterators.
2434 Constant (in the size of the <code>circular_buffer</code>).
2442 <code><a href="#classboost_1_1circular__buffer_1b233a298f5845a0fcf2ecc56f4170810">at() const</a></code>
2449 <a id="classboost_1_1circular__buffer_1cd84838cb4fffb6c113fd0297e502edc" name=
2450 "classboost_1_1circular__buffer_1cd84838cb4fffb6c113fd0297e502edc"></a><code><b><a href=
2451 "#classboost_1_1circular__buffer_1f38a9bc64d84757c661c2542ff9a7f65">reference</a> at(<a href=
2452 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> index);</b></code><br>
2454 Get the element at the <code>index</code> position.
2457 <b>Parameter(s):</b>
2465 The position of the element.
2475 A reference to the element at the <code>index</code> position.
2483 <code>std::out_of_range</code> when the <code>index</code> is invalid (when <code>index >= <a href=
2484 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>).
2489 <b>Exception Safety:</b>
2497 <b>Iterator Invalidation:</b>
2500 Does not invalidate any iterators.
2508 Constant (in the size of the <code>circular_buffer</code>).
2516 <code><a href="#classboost_1_1circular__buffer_1d219f0d3203fb43b964a8cf63f1865cd">operator[]</a></code>
2523 <a id="classboost_1_1circular__buffer_1b233a298f5845a0fcf2ecc56f4170810" name=
2524 "classboost_1_1circular__buffer_1b233a298f5845a0fcf2ecc56f4170810"></a><code><b><a href=
2525 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> at(<a href=
2526 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> index)
2527 const;</b></code><br>
2529 Get the element at the <code>index</code> position.
2532 <b>Parameter(s):</b>
2540 The position of the element.
2550 A const reference to the element at the <code>index</code> position.
2558 <code>std::out_of_range</code> when the <code>index</code> is invalid (when <code>index >= <a href=
2559 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>).
2564 <b>Exception Safety:</b>
2572 <b>Iterator Invalidation:</b>
2575 Does not invalidate any iterators.
2583 Constant (in the size of the <code>circular_buffer</code>).
2591 <code><a href="#classboost_1_1circular__buffer_1eb0a7fe7f8a56a4dc4c933b93adfcef4">operator[]
2599 <a id="classboost_1_1circular__buffer_10d5fdeabeb352f47d1f7bb1ea8d9819f" name=
2600 "classboost_1_1circular__buffer_10d5fdeabeb352f47d1f7bb1ea8d9819f"></a><code><b><a href=
2601 "#classboost_1_1circular__buffer_1f38a9bc64d84757c661c2542ff9a7f65">reference</a> front();</b></code><br>
2603 Get the first element.
2606 <b>Precondition:</b>
2609 <code>!empty()</code>
2617 A reference to the first element of the <code>circular_buffer</code>.
2630 <b>Exception Safety:</b>
2638 <b>Iterator Invalidation:</b>
2641 Does not invalidate any iterators.
2649 Constant (in the size of the <code>circular_buffer</code>).
2657 <code><a href="#classboost_1_1circular__buffer_1d985d974020f88bb4255d8edbae0a30a">back()</a></code>
2664 <a id="classboost_1_1circular__buffer_1d985d974020f88bb4255d8edbae0a30a" name=
2665 "classboost_1_1circular__buffer_1d985d974020f88bb4255d8edbae0a30a"></a><code><b><a href=
2666 "#classboost_1_1circular__buffer_1f38a9bc64d84757c661c2542ff9a7f65">reference</a> back();</b></code><br>
2668 Get the last element.
2671 <b>Precondition:</b>
2674 <code>!empty()</code>
2682 A reference to the last element of the <code>circular_buffer</code>.
2695 <b>Exception Safety:</b>
2703 <b>Iterator Invalidation:</b>
2706 Does not invalidate any iterators.
2714 Constant (in the size of the <code>circular_buffer</code>).
2722 <code><a href="#classboost_1_1circular__buffer_10d5fdeabeb352f47d1f7bb1ea8d9819f">front()</a></code>
2729 <a id="classboost_1_1circular__buffer_10df8595d83bb9d8a7ce50aabc678f90b" name=
2730 "classboost_1_1circular__buffer_10df8595d83bb9d8a7ce50aabc678f90b"></a><code><b><a href=
2731 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> front()
2732 const;</b></code><br>
2734 Get the first element.
2737 <b>Precondition:</b>
2740 <code>!empty()</code>
2748 A const reference to the first element of the <code>circular_buffer</code>.
2761 <b>Exception Safety:</b>
2769 <b>Iterator Invalidation:</b>
2772 Does not invalidate any iterators.
2780 Constant (in the size of the <code>circular_buffer</code>).
2788 <code><a href="#classboost_1_1circular__buffer_1027201797868c6274feb6712f670a132">back()
2796 <a id="classboost_1_1circular__buffer_1027201797868c6274feb6712f670a132" name=
2797 "classboost_1_1circular__buffer_1027201797868c6274feb6712f670a132"></a><code><b><a href=
2798 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> back()
2799 const;</b></code><br>
2801 Get the last element.
2804 <b>Precondition:</b>
2807 <code>!empty()</code>
2815 A const reference to the last element of the <code>circular_buffer</code>.
2828 <b>Exception Safety:</b>
2836 <b>Iterator Invalidation:</b>
2839 Does not invalidate any iterators.
2847 Constant (in the size of the <code>circular_buffer</code>).
2855 <code><a href="#classboost_1_1circular__buffer_10df8595d83bb9d8a7ce50aabc678f90b">front()
2863 <a id="classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d" name=
2864 "classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d"></a><code><b><a href=
2865 "#classboost_1_1circular__buffer_126d279f91fef717e25459a0817ff242f">array_range</a>
2866 array_one();</b></code><br>
2868 Get the first continuous array of the internal buffer.
2870 This method in combination with <code><a href=
2871 "#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two()</a></code> can be useful
2872 when passing the stored data into a legacy C API as an array. Suppose there is a
2873 <code>circular_buffer</code> of capacity 10, containing 7 characters <code>'a', 'b', ..., 'g'</code>
2874 where <code>buff[0] == 'a'</code>, <code>buff[1] == 'b'</code>, ... and <code>buff[6] == 'g'</code>:<br>
2876 <code>circular_buffer<char> buff(10);</code><br>
2878 The internal representation is often not linear and the state of the internal buffer may look like
2881 <code>|e|f|g| | | |a|b|c|d|<br>
2883 begin -------^</code><br>
2885 where <code>|a|b|c|d|</code> represents the "array one", <code>|e|f|g|</code> represents the "array two"
2886 and <code>| | | |</code> is a free space.<br>
2887 Now consider a typical C style function for writing data into a file:<br>
2889 <code>int write(int file_desc, char* buff, int num_bytes);</code><br>
2891 There are two ways how to write the content of the <code>circular_buffer</code> into a file. Either
2892 relying on <code><a href=
2893 "#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one()</a></code> and
2894 <code><a href="#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two()</a></code>
2895 methods and calling the write function twice:<br>
2897 <code>array_range ar = buff.array_one();<br>
2898 write(file_desc, ar.first, ar.second);<br>
2899 ar = buff.array_two();<br>
2900 write(file_desc, ar.first, ar.second);</code><br>
2902 Or relying on the <code><a href=
2903 "#classboost_1_1circular__buffer_1ea728bf57f91aa8946eddf76ce816a4e">linearize()</a></code> method:<br>
2905 <code>write(file_desc, buff.linearize(), buff.size());</code><br>
2907 Since the complexity of <code><a href=
2908 "#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one()</a></code> and
2909 <code><a href="#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two()</a></code>
2910 methods is constant the first option is suitable when calling the write method is "cheap". On the other
2911 hand the second option is more suitable when calling the write method is more "expensive" than calling
2913 "#classboost_1_1circular__buffer_1ea728bf57f91aa8946eddf76ce816a4e">linearize()</a></code> method whose
2914 complexity is linear.
2921 The array range of the first continuous array of the internal buffer. In the case the
2922 <code>circular_buffer</code> is empty the size of the returned array is <code>0</code>.
2935 <b>Exception Safety:</b>
2943 <b>Iterator Invalidation:</b>
2946 Does not invalidate any iterators.
2954 Constant (in the size of the <code>circular_buffer</code>).
2962 In general invoking any method which modifies the internal state of the circular_buffer may delinearize
2963 the internal buffer and invalidate the array ranges returned by <code><a href=
2964 "#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one()</a></code> and
2966 "#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two()</a></code> (and their
2975 In the case the internal buffer is linear e.g. <code>|a|b|c|d|e|f|g| | | |</code> the "array one" is
2976 represented by <code>|a|b|c|d|e|f|g|</code> and the "array two" does not exist (the <code><a href=
2977 "#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two()</a></code> method
2978 returns an array with the size <code>0</code>).
2987 "#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two()</a></code>,
2989 "#classboost_1_1circular__buffer_1ea728bf57f91aa8946eddf76ce816a4e">linearize()</a></code>
2996 <a id="classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b" name=
2997 "classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b"></a><code><b><a href=
2998 "#classboost_1_1circular__buffer_126d279f91fef717e25459a0817ff242f">array_range</a>
2999 array_two();</b></code><br>
3001 Get the second continuous array of the internal buffer.
3003 This method in combination with <code><a href=
3004 "#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one()</a></code> can be useful
3005 when passing the stored data into a legacy C API as an array.
3012 The array range of the second continuous array of the internal buffer. In the case the internal buffer
3013 is linear or the <code>circular_buffer</code> is empty the size of the returned array is
3027 <b>Exception Safety:</b>
3035 <b>Iterator Invalidation:</b>
3038 Does not invalidate any iterators.
3046 Constant (in the size of the <code>circular_buffer</code>).
3055 "#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one()</a></code>
3062 <a id="classboost_1_1circular__buffer_10f4b157e27b1170a571417986b239945" name=
3063 "classboost_1_1circular__buffer_10f4b157e27b1170a571417986b239945"></a><code><b><a href=
3064 "#classboost_1_1circular__buffer_11885d7f475b7e7a74c95b2448d243025">const_array_range</a> array_one()
3065 const;</b></code><br>
3067 Get the first continuous array of the internal buffer.
3069 This method in combination with <code><a href=
3070 "#classboost_1_1circular__buffer_1bb8eb0f298ad2012c55c5303e1f174d5">array_two() const</a></code> can be
3071 useful when passing the stored data into a legacy C API as an array.
3078 The array range of the first continuous array of the internal buffer. In the case the
3079 <code>circular_buffer</code> is empty the size of the returned array is <code>0</code>.
3092 <b>Exception Safety:</b>
3100 <b>Iterator Invalidation:</b>
3103 Does not invalidate any iterators.
3111 Constant (in the size of the <code>circular_buffer</code>).
3119 <code><a href="#classboost_1_1circular__buffer_1bb8eb0f298ad2012c55c5303e1f174d5">array_two()
3120 const</a></code>; <code><a href=
3121 "#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one()</a></code> for more
3122 details how to pass data into a legacy C API.
3129 <a id="classboost_1_1circular__buffer_1bb8eb0f298ad2012c55c5303e1f174d5" name=
3130 "classboost_1_1circular__buffer_1bb8eb0f298ad2012c55c5303e1f174d5"></a><code><b><a href=
3131 "#classboost_1_1circular__buffer_11885d7f475b7e7a74c95b2448d243025">const_array_range</a> array_two()
3132 const;</b></code><br>
3134 Get the second continuous array of the internal buffer.
3136 This method in combination with <code><a href=
3137 "#classboost_1_1circular__buffer_10f4b157e27b1170a571417986b239945">array_one() const</a></code> can be
3138 useful when passing the stored data into a legacy C API as an array.
3145 The array range of the second continuous array of the internal buffer. In the case the internal buffer
3146 is linear or the <code>circular_buffer</code> is empty the size of the returned array is
3160 <b>Exception Safety:</b>
3168 <b>Iterator Invalidation:</b>
3171 Does not invalidate any iterators.
3179 Constant (in the size of the <code>circular_buffer</code>).
3187 <code><a href="#classboost_1_1circular__buffer_10f4b157e27b1170a571417986b239945">array_one()
3195 <a id="classboost_1_1circular__buffer_1ea728bf57f91aa8946eddf76ce816a4e" name=
3196 "classboost_1_1circular__buffer_1ea728bf57f91aa8946eddf76ce816a4e"></a><code><b><a href=
3197 "#classboost_1_1circular__buffer_14ff917f8a6131ec18e91606727592a9c">pointer</a> linearize();</b></code><br>
3199 Linearize the internal buffer into a continuous array.
3201 This method can be useful when passing the stored data into a legacy C API as an array.
3208 <code>&(*this)[0] < &(*this)[1] < ... < &(*this)[<a href=
3209 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> - 1]</code>
3217 A pointer to the beginning of the array or <code>0</code> if empty.
3225 Whatever <code>T::T(const T&)</code> throws.
3228 Whatever <code>T::operator = (const T&)</code> throws.
3233 <b>Exception Safety:</b>
3236 Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything.
3241 <b>Iterator Invalidation:</b>
3244 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
3245 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>);
3246 does not invalidate any iterators if the postcondition (the <i>Effect</i>) is already met prior calling
3255 Linear (in the size of the <code>circular_buffer</code>); constant if the postcondition (the
3256 <i>Effect</i>) is already met.
3264 In general invoking any method which modifies the internal state of the <code>circular_buffer</code>
3265 may delinearize the internal buffer and invalidate the returned pointer.
3274 "#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one()</a></code> and
3276 "#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two()</a></code> for the
3277 other option how to pass data into a legacy C API; <code><a href=
3278 "#classboost_1_1circular__buffer_120f64448dc0723cc68c1096f6b00bc0a">is_linearized()</a></code>,
3280 "#classboost_1_1circular__buffer_1c591bb9e271b10b5240afcff3bd2c619">rotate(const_iterator)</a></code>
3287 <a id="classboost_1_1circular__buffer_120f64448dc0723cc68c1096f6b00bc0a" name=
3288 "classboost_1_1circular__buffer_120f64448dc0723cc68c1096f6b00bc0a"></a><code><b>bool is_linearized()
3289 const;</b></code><br>
3291 Is the <code>circular_buffer</code> linearized?
3297 <code>true</code> if the internal buffer is linearized into a continuous array (i.e. the
3298 <code>circular_buffer</code> meets a condition <code>&(*this)[0] < &(*this)[1] < ... <
3299 &(*this)[<a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> -
3300 1]</code>); <code>false</code> otherwise.
3313 <b>Exception Safety:</b>
3321 <b>Iterator Invalidation:</b>
3324 Does not invalidate any iterators.
3332 Constant (in the size of the <code>circular_buffer</code>).
3341 "#classboost_1_1circular__buffer_1ea728bf57f91aa8946eddf76ce816a4e">linearize()</a></code>,
3343 "#classboost_1_1circular__buffer_1957cccdcb0c4ef7d80a34a990065818d">array_one()</a></code>,
3345 "#classboost_1_1circular__buffer_1f5081a54afbc2dfc1a7fb20329df7d5b">array_two()</a></code>
3352 <a id="classboost_1_1circular__buffer_1c591bb9e271b10b5240afcff3bd2c619" name=
3353 "classboost_1_1circular__buffer_1c591bb9e271b10b5240afcff3bd2c619"></a><code><b>void rotate(<a href=
3354 "#classboost_1_1circular__buffer_15cab6d46f03c40d1e52d41843319ddb9">const_iterator</a>
3355 new_begin);</b></code><br>
3357 Rotate elements in the <code>circular_buffer</code>.
3359 A more effective implementation of <code><a href=
3360 "http://www.sgi.com/tech/stl/rotate.html">std::rotate</a></code>.
3364 <b>Precondition:</b>
3367 <code>new_begin</code> is a valid iterator pointing to the <code>circular_buffer</code> <b>except</b>
3376 Before calling the method suppose:<br>
3378 <code>m == std::distance(new_begin, <a href=
3379 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>)</code><br>
3380 <code>n == std::distance(<a href=
3381 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, new_begin)</code><br>
3382 <code>val_0 == *new_begin, val_1 == *(new_begin + 1), ... val_m == *(new_begin + m)</code><br>
3383 <code>val_r1 == *(new_begin - 1), val_r2 == *(new_begin - 2), ... val_rn == *(new_begin - n)</code><br>
3385 then after call to the method:<br>
3387 <code>val_0 == (*this)[0] && val_1 == (*this)[1] && ... && val_m == (*this)[m -
3388 1] && val_r1 == (*this)[m + n - 1] && val_r2 == (*this)[m + n - 2] && ...
3389 && val_rn == (*this)[m]</code>
3394 <b>Parameter(s):</b>
3399 <code>new_begin</code>
3412 Whatever <code>T::T(const T&)</code> throws.
3415 Whatever <code>T::operator = (const T&)</code> throws.
3420 <b>Exception Safety:</b>
3423 Basic; no-throw if the <code>circular_buffer</code> is full or <code>new_begin</code> points to
3424 <code><a href="#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code> or
3425 if the operations in the <i>Throws</i> section do not throw anything.
3430 <b>Iterator Invalidation:</b>
3433 If <code>m < n</code> invalidates iterators pointing to the last <code>m</code> elements
3434 (<b>including</b> <code>new_begin</code>, but not iterators equal to <code><a href=
3435 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>) else invalidates
3436 iterators pointing to the first <code>n</code> elements; does not invalidate any iterators if the
3437 <code>circular_buffer</code> is full.
3445 Linear (in <code>(std::min)(m, n)</code>); constant if the <code>circular_buffer</code> is full.
3453 <code><a href="http://www.sgi.com/tech/stl/rotate.html">std::rotate</a></code>
3460 <a id="classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32" name=
3461 "classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32"></a><code><b><a href=
3462 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> size()
3463 const;</b></code><br>
3465 Get the number of elements currently stored in the <code>circular_buffer</code>.
3471 The number of elements stored in the <code>circular_buffer</code>.
3484 <b>Exception Safety:</b>
3492 <b>Iterator Invalidation:</b>
3495 Does not invalidate any iterators.
3503 Constant (in the size of the <code>circular_buffer</code>).
3512 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a></code>,
3514 "#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size()</a></code>,
3515 <code><a href="#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a></code>,
3516 <code><a href="#classboost_1_1circular__buffer_180c2e2e66a8fa9d0b7adc1b54921a8c3">resize(size_type,
3517 const_reference)</a></code>
3524 <a id="classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7" name=
3525 "classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7"></a><code><b><a href=
3526 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> max_size()
3527 const;</b></code><br>
3529 Get the largest possible size or capacity of the <code>circular_buffer</code>. (It depends on allocator's
3536 The maximum size/capacity the <code>circular_buffer</code> can be set to.
3549 <b>Exception Safety:</b>
3557 <b>Iterator Invalidation:</b>
3560 Does not invalidate any iterators.
3568 Constant (in the size of the <code>circular_buffer</code>).
3576 <code><a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>,
3578 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a></code>,
3579 <code><a href="#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a></code>
3586 <a id="classboost_1_1circular__buffer_15be1c2a005ec9828549ef6dd7ebed583" name=
3587 "classboost_1_1circular__buffer_15be1c2a005ec9828549ef6dd7ebed583"></a><code><b>bool empty()
3588 const;</b></code><br>
3590 Is the <code>circular_buffer</code> empty?
3596 <code>true</code> if there are no elements stored in the <code>circular_buffer</code>;
3597 <code>false</code> otherwise.
3610 <b>Exception Safety:</b>
3618 <b>Iterator Invalidation:</b>
3621 Does not invalidate any iterators.
3629 Constant (in the size of the <code>circular_buffer</code>).
3637 <code><a href="#classboost_1_1circular__buffer_1fd0eef8ba91210d1575404b7e3e8207a">full()</a></code>
3644 <a id="classboost_1_1circular__buffer_1fd0eef8ba91210d1575404b7e3e8207a" name=
3645 "classboost_1_1circular__buffer_1fd0eef8ba91210d1575404b7e3e8207a"></a><code><b>bool full()
3646 const;</b></code><br>
3648 Is the <code>circular_buffer</code> full?
3654 <code>true</code> if the number of elements stored in the <code>circular_buffer</code> equals the
3655 capacity of the <code>circular_buffer</code>; <code>false</code> otherwise.
3668 <b>Exception Safety:</b>
3676 <b>Iterator Invalidation:</b>
3679 Does not invalidate any iterators.
3687 Constant (in the size of the <code>circular_buffer</code>).
3695 <code><a href="#classboost_1_1circular__buffer_15be1c2a005ec9828549ef6dd7ebed583">empty()</a></code>
3702 <a id="classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de" name=
3703 "classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de"></a><code><b><a href=
3704 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> reserve()
3705 const;</b></code><br>
3707 Get the maximum number of elements which can be inserted into the <code>circular_buffer</code> without
3708 overwriting any of already stored elements.
3714 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> -
3715 <a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>
3728 <b>Exception Safety:</b>
3736 <b>Iterator Invalidation:</b>
3739 Does not invalidate any iterators.
3747 Constant (in the size of the <code>circular_buffer</code>).
3756 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a></code>,
3757 <code><a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>,
3758 <code><a href="#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size()</a></code>
3765 <a id="classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77" name=
3766 "classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77"></a><code><b><a href=
3767 "#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> capacity()
3768 const;</b></code><br>
3770 Get the capacity of the <code>circular_buffer</code>.
3776 The maximum number of elements which can be stored in the <code>circular_buffer</code>.
3789 <b>Exception Safety:</b>
3797 <b>Iterator Invalidation:</b>
3800 Does not invalidate any iterators.
3808 Constant (in the size of the <code>circular_buffer</code>).
3816 <code><a href="#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a></code>,
3817 <code><a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>,
3819 "#classboost_1_1circular__buffer_157e2d506bc274b2a63fbe1b8fcafebd7">max_size()</a></code>,
3821 "#classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f">set_capacity(capacity_type)</a></code>
3828 <a id="classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f" name=
3829 "classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f"></a><code><b>void set_capacity(<a href=
3830 "#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a>
3831 new_capacity);</b></code><br>
3833 Change the capacity of the <code>circular_buffer</code>.
3839 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
3840 new_capacity && <a href=
3841 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> <=
3842 new_capacity</code><br>
3844 If the current number of elements stored in the <code>circular_buffer</code> is greater than the
3845 desired new capacity then number of <code>[<a href=
3846 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> - new_capacity]</code>
3847 <b>last</b> elements will be removed and the new size will be equal to <code>new_capacity</code>.
3852 <b>Parameter(s):</b>
3857 <code>new_capacity</code>
3870 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
3874 Whatever <code>T::T(const T&)</code> throws.
3879 <b>Exception Safety:</b>
3887 <b>Iterator Invalidation:</b>
3890 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
3891 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>) if
3892 the new capacity is different from the original.
3900 Linear (in <code>min[<a href=
3901 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>, new_capacity]</code>).
3910 "#classboost_1_1circular__buffer_1477715e9d31d2cc5b02ad8ecf3c68c46">rset_capacity(capacity_type)</a></code>,
3911 <code><a href="#classboost_1_1circular__buffer_180c2e2e66a8fa9d0b7adc1b54921a8c3">resize(size_type,
3912 const_reference)</a></code>
3919 <a id="classboost_1_1circular__buffer_180c2e2e66a8fa9d0b7adc1b54921a8c3" name=
3920 "classboost_1_1circular__buffer_180c2e2e66a8fa9d0b7adc1b54921a8c3"></a><code><b>void resize(<a href=
3921 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> new_size, <a href=
3922 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item =
3923 value_type());</b></code><br>
3925 Change the size of the <code>circular_buffer</code>.
3931 <code><a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
3932 new_size && <a href=
3933 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> >=
3936 If the new size is greater than the current size, copies of <code>item</code> will be inserted at the
3937 <b>back</b> of the of the <code>circular_buffer</code> in order to achieve the desired size. In the
3938 case the resulting size exceeds the current capacity the capacity will be set to
3939 <code>new_size</code>.<br>
3940 If the current number of elements stored in the <code>circular_buffer</code> is greater than the
3941 desired new size then number of <code>[<a href=
3942 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> - new_size]</code>
3943 <b>last</b> elements will be removed. (The capacity will remain unchanged.)
3948 <b>Parameter(s):</b>
3953 <code>new_size</code>
3966 The element the <code>circular_buffer</code> will be filled with in order to gain the requested
3967 size. (See the <i>Effect</i>.)
3977 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
3981 Whatever <code>T::T(const T&)</code> throws.
3986 <b>Exception Safety:</b>
3994 <b>Iterator Invalidation:</b>
3997 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
3998 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>) if
3999 the new size is greater than the current capacity. Invalidates iterators pointing to the removed
4000 elements if the new size is lower that the original size. Otherwise it does not invalidate any
4009 Linear (in the new size of the <code>circular_buffer</code>).
4017 <code><a href="#classboost_1_1circular__buffer_144ecd9ec5f54a2d61c7d132e445d3483">rresize(size_type,
4018 const_reference)</a></code>, <code><a href=
4019 "#classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f">set_capacity(capacity_type)</a></code>
4026 <a id="classboost_1_1circular__buffer_1477715e9d31d2cc5b02ad8ecf3c68c46" name=
4027 "classboost_1_1circular__buffer_1477715e9d31d2cc5b02ad8ecf3c68c46"></a><code><b>void rset_capacity(<a href=
4028 "#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a>
4029 new_capacity);</b></code><br>
4031 Change the capacity of the <code>circular_buffer</code>.
4037 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
4038 new_capacity && <a href=
4039 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> <=
4040 new_capacity</code><br>
4042 If the current number of elements stored in the <code>circular_buffer</code> is greater than the
4043 desired new capacity then number of <code>[<a href=
4044 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> - new_capacity]</code>
4045 <b>first</b> elements will be removed and the new size will be equal to <code>new_capacity</code>.
4050 <b>Parameter(s):</b>
4055 <code>new_capacity</code>
4068 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
4072 Whatever <code>T::T(const T&)</code> throws.
4077 <b>Exception Safety:</b>
4085 <b>Iterator Invalidation:</b>
4088 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
4089 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>) if
4090 the new capacity is different from the original.
4098 Linear (in <code>min[<a href=
4099 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a>, new_capacity]</code>).
4108 "#classboost_1_1circular__buffer_161714204ef5172d156e2c7eccd04998f">set_capacity(capacity_type)</a></code>,
4109 <code><a href="#classboost_1_1circular__buffer_144ecd9ec5f54a2d61c7d132e445d3483">rresize(size_type,
4110 const_reference)</a></code>
4117 <a id="classboost_1_1circular__buffer_144ecd9ec5f54a2d61c7d132e445d3483" name=
4118 "classboost_1_1circular__buffer_144ecd9ec5f54a2d61c7d132e445d3483"></a><code><b>void rresize(<a href=
4119 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> new_size, <a href=
4120 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item =
4121 value_type());</b></code><br>
4123 Change the size of the <code>circular_buffer</code>.
4129 <code><a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
4130 new_size && <a href=
4131 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> >=
4134 If the new size is greater than the current size, copies of <code>item</code> will be inserted at the
4135 <b>front</b> of the of the <code>circular_buffer</code> in order to achieve the desired size. In the
4136 case the resulting size exceeds the current capacity the capacity will be set to
4137 <code>new_size</code>.<br>
4138 If the current number of elements stored in the <code>circular_buffer</code> is greater than the
4139 desired new size then number of <code>[<a href=
4140 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> - new_size]</code>
4141 <b>first</b> elements will be removed. (The capacity will remain unchanged.)
4146 <b>Parameter(s):</b>
4151 <code>new_size</code>
4164 The element the <code>circular_buffer</code> will be filled with in order to gain the requested
4165 size. (See the <i>Effect</i>.)
4175 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
4179 Whatever <code>T::T(const T&)</code> throws.
4184 <b>Exception Safety:</b>
4192 <b>Iterator Invalidation:</b>
4195 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
4196 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>) if
4197 the new size is greater than the current capacity. Invalidates iterators pointing to the removed
4198 elements if the new size is lower that the original size. Otherwise it does not invalidate any
4207 Linear (in the new size of the <code>circular_buffer</code>).
4215 <code><a href="#classboost_1_1circular__buffer_180c2e2e66a8fa9d0b7adc1b54921a8c3">resize(size_type,
4216 const_reference)</a></code>, <code><a href=
4217 "#classboost_1_1circular__buffer_1477715e9d31d2cc5b02ad8ecf3c68c46">rset_capacity(capacity_type)</a></code>
4224 <a id="classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d" name=
4225 "classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d"></a><code><b>circular_buffer<T,Alloc>&
4226 operator=(const circular_buffer<T,Alloc>& cb);</b></code><br>
4228 The assign operator.
4230 Makes this <code>circular_buffer</code> to become a copy of the specified <code>circular_buffer</code>.
4237 <code>*this == cb</code>
4242 <b>Parameter(s):</b>
4250 The <code>circular_buffer</code> to be copied.
4260 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
4264 Whatever <code>T::T(const T&)</code> throws.
4269 <b>Exception Safety:</b>
4277 <b>Iterator Invalidation:</b>
4280 Invalidates all iterators pointing to this <code>circular_buffer</code> (except iterators equal to
4281 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
4289 Linear (in the size of <code>cb</code>).
4297 <code><a href="#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
4298 const_reference)</a></code>, <code><a href=
4299 "#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign(capacity_type, size_type,
4300 const_reference)</a></code>, <code><a href=
4301 "#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign(InputIterator,
4302 InputIterator)</a></code>, <code><a href=
4303 "#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign(capacity_type,
4304 InputIterator, InputIterator)</a></code>
4311 <a id="classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada" name=
4312 "classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada"></a><code><b>void assign(<a href=
4313 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
4314 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a>
4315 item);</b></code><br>
4317 Assign <code>n</code> items into the <code>circular_buffer</code>.
4319 The content of the <code>circular_buffer</code> will be removed and replaced with <code>n</code> copies
4320 of the <code>item</code>.
4327 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> == n
4328 && <a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n
4329 && (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1]
4335 <b>Parameter(s):</b>
4343 The number of elements the <code>circular_buffer</code> will be filled with.
4353 The element the <code>circular_buffer</code> will be filled with.
4363 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
4367 Whatever <code>T::T(const T&)</code> throws.
4372 <b>Exception Safety:</b>
4380 <b>Iterator Invalidation:</b>
4383 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
4384 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
4392 Linear (in the <code>n</code>).
4400 <code><a href="#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a></code>,
4401 <code><a href="#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign(capacity_type,
4402 size_type, const_reference)</a></code>, <code><a href=
4403 "#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign(InputIterator,
4404 InputIterator)</a></code>, <code><a href=
4405 "#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign(capacity_type,
4406 InputIterator, InputIterator)</a></code>
4413 <a id="classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a" name=
4414 "classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a"></a><code><b>void assign(<a href=
4415 "#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
4416 <a href="#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
4417 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a>
4418 item);</b></code><br>
4420 Assign <code>n</code> items into the <code>circular_buffer</code> specifying the capacity.
4422 The capacity of the <code>circular_buffer</code> will be set to the specified value and the content of
4423 the <code>circular_buffer</code> will be removed and replaced with <code>n</code> copies of the
4428 <b>Precondition:</b>
4431 <code>capacity >= n</code>
4439 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
4440 buffer_capacity && <a href=
4441 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == n &&
4442 (*this)[0] == item && (*this)[1] == item && ... && (*this) [n - 1] ==
4448 <b>Parameter(s):</b>
4453 <code>buffer_capacity</code>
4466 The number of elements the <code>circular_buffer</code> will be filled with.
4476 The element the <code>circular_buffer</code> will be filled with.
4486 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
4490 Whatever <code>T::T(const T&)</code> throws.
4495 <b>Exception Safety:</b>
4503 <b>Iterator Invalidation:</b>
4506 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
4507 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
4515 Linear (in the <code>n</code>).
4523 <code><a href="#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a></code>,
4524 <code><a href="#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
4525 const_reference)</a></code>, <code><a href=
4526 "#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign(InputIterator,
4527 InputIterator)</a></code>, <code><a href=
4528 "#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign(capacity_type,
4529 InputIterator, InputIterator)</a></code>
4536 <a id="classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c" name=
4537 "classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c"></a> <code><b>template <class
4538 InputIterator><br>
4539 void assign(InputIterator first, InputIterator last);</b></code><br>
4541 Assign a copy of the range into the <code>circular_buffer</code>.
4543 The content of the <code>circular_buffer</code> will be removed and replaced with copies of elements from
4544 the specified range.
4548 <b>Precondition:</b>
4551 Valid range <code>[first, last)</code>.<br>
4552 <code>first</code> and <code>last</code> have to meet the requirements of <a href=
4553 "http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
4561 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
4562 std::distance(first, last) && <a href=
4563 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> == std::distance(first,
4564 last) && (*this)[0]== *first && (*this)[1] == *(first + 1) && ... &&
4565 (*this)[std::distance(first, last) - 1] == *(last - 1)</code>
4570 <b>Parameter(s):</b>
4578 The beginning of the range to be copied.
4588 The end of the range to be copied.
4598 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
4602 Whatever <code>T::T(const T&)</code> throws.
4607 <b>Exception Safety:</b>
4615 <b>Iterator Invalidation:</b>
4618 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
4619 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
4627 Linear (in the <code>std::distance(first, last)</code>).
4635 <code><a href="#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a></code>,
4636 <code><a href="#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
4637 const_reference)</a></code>, <code><a href=
4638 "#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign(capacity_type, size_type,
4639 const_reference)</a></code>, <code><a href=
4640 "#classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366">assign(capacity_type,
4641 InputIterator, InputIterator)</a></code>
4648 <a id="classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366" name=
4649 "classboost_1_1circular__buffer_127cab6034beeeb0e11863c8c14d14366"></a> <code><b>template <class
4650 InputIterator><br>
4651 void assign(<a href=
4652 "#classboost_1_1circular__buffer_1dc642ff2be4db0be1a457810e5d09595">capacity_type</a> buffer_capacity,
4653 InputIterator first, InputIterator last);</b></code><br>
4655 Assign a copy of the range into the <code>circular_buffer</code> specifying the capacity.
4657 The capacity of the <code>circular_buffer</code> will be set to the specified value and the content of
4658 the <code>circular_buffer</code> will be removed and replaced with copies of elements from the specified
4663 <b>Precondition:</b>
4666 Valid range <code>[first, last)</code>.<br>
4667 <code>first</code> and <code>last</code> have to meet the requirements of <a href=
4668 "http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
4676 <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a> ==
4677 buffer_capacity && <a href=
4678 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> <=
4679 std::distance(first, last) && (*this)[0]== *(last - buffer_capacity) && (*this)[1] ==
4680 *(last - buffer_capacity + 1) && ... && (*this)[buffer_capacity - 1] == *(last -
4683 If the number of items to be copied from the range <code>[first, last)</code> is greater than the
4684 specified <code>buffer_capacity</code> then only elements from the range <code>[last - buffer_capacity,
4685 last)</code> will be copied.
4690 <b>Parameter(s):</b>
4695 <code>buffer_capacity</code>
4708 The beginning of the range to be copied.
4718 The end of the range to be copied.
4728 An allocation error if memory is exhausted (<code>std::bad_alloc</code> if the standard allocator is
4732 Whatever <code>T::T(const T&)</code> throws.
4737 <b>Exception Safety:</b>
4745 <b>Iterator Invalidation:</b>
4748 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
4749 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
4757 Linear (in <code>std::distance(first, last)</code>; in <code>min[capacity, std::distance(first,
4758 last)]</code> if the <code>InputIterator</code> is a <a href=
4759 "http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
4767 <code><a href="#classboost_1_1circular__buffer_1db1558911b2e251a587aeb3d8b3d797d">operator=</a></code>,
4768 <code><a href="#classboost_1_1circular__buffer_19ba4a81df16f386d31b04b49c82d1ada">assign(size_type,
4769 const_reference)</a></code>, <code><a href=
4770 "#classboost_1_1circular__buffer_1dbebb80a5f38e52a37ec9f3ed765600a">assign(capacity_type, size_type,
4771 const_reference)</a></code>, <code><a href=
4772 "#classboost_1_1circular__buffer_1253302d9bda5d7efbc4a6c311de3790c">assign(InputIterator,
4773 InputIterator)</a></code>
4780 <a id="classboost_1_1circular__buffer_1270ab7074c365663a6f18808024fd88b" name=
4781 "classboost_1_1circular__buffer_1270ab7074c365663a6f18808024fd88b"></a><code><b>void
4782 swap(circular_buffer<T,Alloc>& cb);</b></code><br>
4784 Swap the contents of two <code>circular_buffer</code>s.
4790 <code>this</code> contains elements of <code>cb</code> and vice versa; the capacity of
4791 <code>this</code> equals to the capacity of <code>cb</code> and vice versa.
4796 <b>Parameter(s):</b>
4804 The <code>circular_buffer</code> whose content will be swapped.
4819 <b>Exception Safety:</b>
4827 <b>Iterator Invalidation:</b>
4830 Invalidates all iterators of both <code>circular_buffer</code>s. (On the other hand the iterators still
4831 point to the same elements but within another container. If you want to rely on this feature you have
4832 to turn the <a href="#debug">Debug Support</a> off otherwise an assertion will report an error if such
4833 invalidated iterator is used.)
4841 Constant (in the size of the <code>circular_buffer</code>).
4849 <code><a href="#namespaceboost_14aa8f6a2c9640f3f22e266f0fca85777">swap(circular_buffer<T,
4850 Alloc>&, circular_buffer<T, Alloc>&)</a></code>
4857 <a id="classboost_1_1circular__buffer_1aa35dd7ef8eb1d04508494d1835cc82e" name=
4858 "classboost_1_1circular__buffer_1aa35dd7ef8eb1d04508494d1835cc82e"></a><code><b>void push_back(<a href=
4859 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item =
4860 value_type());</b></code><br>
4862 Insert a new element at the end of the <code>circular_buffer</code>.
4868 if <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a>
4869 > 0</code> then <code><a href=
4870 "#classboost_1_1circular__buffer_1d985d974020f88bb4255d8edbae0a30a">back()</a> == item</code><br>
4871 If the <code>circular_buffer</code> is full, the first element will be removed. If the capacity is
4872 <code>0</code>, nothing will be inserted.
4877 <b>Parameter(s):</b>
4885 The element to be inserted.
4895 Whatever <code>T::T(const T&)</code> throws.
4898 Whatever <code>T::operator = (const T&)</code> throws.
4903 <b>Exception Safety:</b>
4906 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
4911 <b>Iterator Invalidation:</b>
4914 Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
4922 Constant (in the size of the <code>circular_buffer</code>).
4931 "#classboost_1_1circular__buffer_10ef57e73c193682a649d8eb4a1096dce">push_front(const_reference)</a></code>,
4933 "#classboost_1_1circular__buffer_1df0da00cb501bea75afbbfab9f546a07">pop_back()</a></code>,
4935 "#classboost_1_1circular__buffer_18ac972dc24ef7236faa1875de92b9dd8">pop_front()</a></code>
4942 <a id="classboost_1_1circular__buffer_10ef57e73c193682a649d8eb4a1096dce" name=
4943 "classboost_1_1circular__buffer_10ef57e73c193682a649d8eb4a1096dce"></a><code><b>void push_front(<a href=
4944 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item =
4945 value_type());</b></code><br>
4947 Insert a new element at the beginning of the <code>circular_buffer</code>.
4953 if <code><a href="#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a>
4954 > 0</code> then <code><a href=
4955 "#classboost_1_1circular__buffer_10d5fdeabeb352f47d1f7bb1ea8d9819f">front()</a> == item</code><br>
4956 If the <code>circular_buffer</code> is full, the last element will be removed. If the capacity is
4957 <code>0</code>, nothing will be inserted.
4962 <b>Parameter(s):</b>
4970 The element to be inserted.
4980 Whatever <code>T::T(const T&)</code> throws.
4983 Whatever <code>T::operator = (const T&)</code> throws.
4988 <b>Exception Safety:</b>
4991 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
4996 <b>Iterator Invalidation:</b>
4999 Does not invalidate any iterators with the exception of iterators pointing to the overwritten element.
5007 Constant (in the size of the <code>circular_buffer</code>).
5016 "#classboost_1_1circular__buffer_1aa35dd7ef8eb1d04508494d1835cc82e">push_back(const_reference)</a></code>,
5018 "#classboost_1_1circular__buffer_1df0da00cb501bea75afbbfab9f546a07">pop_back()</a></code>,
5020 "#classboost_1_1circular__buffer_18ac972dc24ef7236faa1875de92b9dd8">pop_front()</a></code>
5027 <a id="classboost_1_1circular__buffer_1df0da00cb501bea75afbbfab9f546a07" name=
5028 "classboost_1_1circular__buffer_1df0da00cb501bea75afbbfab9f546a07"></a><code><b>void
5029 pop_back();</b></code><br>
5031 Remove the last element from the <code>circular_buffer</code>.
5034 <b>Precondition:</b>
5037 <code>!empty()</code>
5045 The last element is removed from the <code>circular_buffer</code>.
5058 <b>Exception Safety:</b>
5066 <b>Iterator Invalidation:</b>
5069 Invalidates only iterators pointing to the removed element.
5077 Constant (in the size of the <code>circular_buffer</code>).
5086 "#classboost_1_1circular__buffer_18ac972dc24ef7236faa1875de92b9dd8">pop_front()</a></code>,
5088 "#classboost_1_1circular__buffer_1aa35dd7ef8eb1d04508494d1835cc82e">push_back(const_reference)</a></code>,
5090 "#classboost_1_1circular__buffer_10ef57e73c193682a649d8eb4a1096dce">push_front(const_reference)</a></code>
5097 <a id="classboost_1_1circular__buffer_18ac972dc24ef7236faa1875de92b9dd8" name=
5098 "classboost_1_1circular__buffer_18ac972dc24ef7236faa1875de92b9dd8"></a><code><b>void
5099 pop_front();</b></code><br>
5101 Remove the first element from the <code>circular_buffer</code>.
5104 <b>Precondition:</b>
5107 <code>!empty()</code>
5115 The first element is removed from the <code>circular_buffer</code>.
5128 <b>Exception Safety:</b>
5136 <b>Iterator Invalidation:</b>
5139 Invalidates only iterators pointing to the removed element.
5147 Constant (in the size of the <code>circular_buffer</code>).
5156 "#classboost_1_1circular__buffer_1df0da00cb501bea75afbbfab9f546a07">pop_back()</a></code>,
5158 "#classboost_1_1circular__buffer_1aa35dd7ef8eb1d04508494d1835cc82e">push_back(const_reference)</a></code>,
5160 "#classboost_1_1circular__buffer_10ef57e73c193682a649d8eb4a1096dce">push_front(const_reference)</a></code>
5167 <a id="classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95" name=
5168 "classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95"></a><code><b><a href=
5169 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> insert(<a href=
5170 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> pos, <a href=
5171 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item =
5172 value_type());</b></code><br>
5174 Insert an element at the specified position.
5177 <b>Precondition:</b>
5180 <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end.
5188 The <code>item</code> will be inserted at the position <code>pos</code>.<br>
5189 If the <code>circular_buffer</code> is full, the first element will be overwritten. If the
5190 <code>circular_buffer</code> is full and the <code>pos</code> points to <code><a href=
5191 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code>, then the
5192 <code>item</code> will not be inserted. If the capacity is <code>0</code>, nothing will be inserted.
5197 <b>Parameter(s):</b>
5205 An iterator specifying the position where the <code>item</code> will be inserted.
5215 The element to be inserted.
5225 Iterator to the inserted element or <code><a href=
5226 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code> if the
5227 <code>item</code> is not inserted. (See the <i>Effect</i>.)
5235 Whatever <code>T::T(const T&)</code> throws.
5238 Whatever <code>T::operator = (const T&)</code> throws.
5243 <b>Exception Safety:</b>
5246 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
5251 <b>Iterator Invalidation:</b>
5254 Invalidates iterators pointing to the elements at the insertion point (including <code>pos</code>) and
5255 iterators behind the insertion point (towards the end; except iterators equal to <code><a href=
5256 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>). It also
5257 invalidates iterators pointing to the overwritten element.
5265 Linear (in <code>std::distance(pos, <a href=
5266 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>)</code>).
5274 <code><a href="#classboost_1_1circular__buffer_1b2f197c99d47138db777f0a46783b140">insert(iterator,
5275 size_type, value_type)</a></code>, <code><a href=
5276 "#classboost_1_1circular__buffer_1d00091d1d794cab3264b3674e99b33f6">insert(iterator, InputIterator,
5277 InputIterator)</a></code>, <code><a href=
5278 "#classboost_1_1circular__buffer_12c9332f457bf5bb3128463cf528c058c">rinsert(iterator,
5279 value_type)</a></code>, <code><a href=
5280 "#classboost_1_1circular__buffer_1a47a5358db1b7d7e4925c16db13d2fc5">rinsert(iterator, size_type,
5281 value_type)</a></code>, <code><a href=
5282 "#classboost_1_1circular__buffer_1d6479cbc43a304bdbf04262f957fa323">rinsert(iterator, InputIterator,
5283 InputIterator)</a></code>
5290 <a id="classboost_1_1circular__buffer_1b2f197c99d47138db777f0a46783b140" name=
5291 "classboost_1_1circular__buffer_1b2f197c99d47138db777f0a46783b140"></a><code><b>void insert(<a href=
5292 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> pos, <a href=
5293 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
5294 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a>
5295 item);</b></code><br>
5297 Insert <code>n</code> copies of the <code>item</code> at the specified position.
5300 <b>Precondition:</b>
5303 <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end.
5311 The number of <code>min[n, (pos - <a href=
5312 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>) + <a href=
5313 "#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a>]</code> elements will
5314 be inserted at the position <code>pos</code>.<br>
5315 The number of <code>min[pos - <a href=
5316 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, max[0, n - <a href=
5317 "#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a>]]</code> elements
5318 will be overwritten at the beginning of the <code>circular_buffer</code>.<br>
5319 (See <i>Example</i> for the explanation.)
5324 <b>Parameter(s):</b>
5332 An iterator specifying the position where the <code>item</code>s will be inserted.
5342 The number of <code>item</code>s the to be inserted.
5352 The element whose copies will be inserted.
5362 Whatever <code>T::T(const T&)</code> throws.
5365 Whatever <code>T::operator = (const T&)</code> throws.
5370 <b>Exception Safety:</b>
5373 Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything.
5378 <b>Iterator Invalidation:</b>
5381 Invalidates iterators pointing to the elements at the insertion point (including <code>pos</code>) and
5382 iterators behind the insertion point (towards the end; except iterators equal to <code><a href=
5383 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>). It also
5384 invalidates iterators pointing to the overwritten elements.
5392 Linear (in <code>min[<a href=
5393 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a>, std::distance(pos,
5394 <a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>) + n]</code>).
5402 Consider a <code>circular_buffer</code> with the capacity of 6 and the size of 4. Its internal buffer
5403 may look like the one below.<br>
5405 <code>|1|2|3|4| | |</code><br>
5406 <code>p ---^</code><br>
5408 After inserting 5 elements at the position <code>p</code>:<br>
5410 <code>insert(p, (size_t)5, 0);</code><br>
5412 actually only 4 elements get inserted and elements <code>1</code> and <code>2</code> are overwritten.
5413 This is due to the fact the insert operation preserves the capacity. After insertion the internal
5414 buffer looks like this:<br>
5416 <code>|0|0|0|0|3|4|</code><br>
5418 For comparison if the capacity would not be preserved the internal buffer would then result in
5419 <code>|1|2|0|0|0|0|0|3|4|</code>.
5427 <code><a href="#classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95">insert(iterator,
5428 value_type)</a></code>, <code><a href=
5429 "#classboost_1_1circular__buffer_1d00091d1d794cab3264b3674e99b33f6">insert(iterator, InputIterator,
5430 InputIterator)</a></code>, <code><a href=
5431 "#classboost_1_1circular__buffer_12c9332f457bf5bb3128463cf528c058c">rinsert(iterator,
5432 value_type)</a></code>, <code><a href=
5433 "#classboost_1_1circular__buffer_1a47a5358db1b7d7e4925c16db13d2fc5">rinsert(iterator, size_type,
5434 value_type)</a></code>, <code><a href=
5435 "#classboost_1_1circular__buffer_1d6479cbc43a304bdbf04262f957fa323">rinsert(iterator, InputIterator,
5436 InputIterator)</a></code>
5443 <a id="classboost_1_1circular__buffer_1d00091d1d794cab3264b3674e99b33f6" name=
5444 "classboost_1_1circular__buffer_1d00091d1d794cab3264b3674e99b33f6"></a> <code><b>template <class
5445 InputIterator><br>
5446 void insert(<a href="#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a>
5447 pos, InputIterator first, InputIterator last);</b></code><br>
5449 Insert the range <code>[first, last)</code> at the specified position.
5452 <b>Precondition:</b>
5455 <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end.<br>
5456 Valid range <code>[first, last)</code> where <code>first</code> and <code>last</code> meet the
5457 requirements of an <a href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
5465 Elements from the range <code>[first + max[0, distance(first, last) - (pos - <a href=
5466 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>) - <a href=
5467 "#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a>], last)</code> will
5468 be inserted at the position <code>pos</code>.<br>
5469 The number of <code>min[pos - <a href=
5470 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, max[0, distance(first,
5472 "#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a>]]</code> elements
5473 will be overwritten at the beginning of the <code>circular_buffer</code>.<br>
5474 (See <i>Example</i> for the explanation.)
5479 <b>Parameter(s):</b>
5487 An iterator specifying the position where the range will be inserted.
5497 The beginning of the range to be inserted.
5507 The end of the range to be inserted.
5517 Whatever <code>T::T(const T&)</code> throws.
5520 Whatever <code>T::operator = (const T&)</code> throws.
5525 <b>Exception Safety:</b>
5528 Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything.
5533 <b>Iterator Invalidation:</b>
5536 Invalidates iterators pointing to the elements at the insertion point (including <code>pos</code>) and
5537 iterators behind the insertion point (towards the end; except iterators equal to <code><a href=
5538 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>). It also
5539 invalidates iterators pointing to the overwritten elements.
5547 Linear (in <code>[std::distance(pos, <a href=
5548 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>) + std::distance(first,
5549 last)]</code>; in <code>min[<a href=
5550 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a>, std::distance(pos,
5551 <a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>) +
5552 std::distance(first, last)]</code> if the <code>InputIterator</code> is a <a href=
5553 "http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
5561 Consider a <code>circular_buffer</code> with the capacity of 6 and the size of 4. Its internal buffer
5562 may look like the one below.<br>
5564 <code>|1|2|3|4| | |</code><br>
5565 <code>p ---^</code><br>
5567 After inserting a range of elements at the position <code>p</code>:<br>
5569 <code>int array[] = { 5, 6, 7, 8, 9 };</code><br>
5570 <code>insert(p, array, array + 5);</code><br>
5572 actually only elements <code>6</code>, <code>7</code>, <code>8</code> and <code>9</code> from the
5573 specified range get inserted and elements <code>1</code> and <code>2</code> are overwritten. This is
5574 due to the fact the insert operation preserves the capacity. After insertion the internal buffer looks
5577 <code>|6|7|8|9|3|4|</code><br>
5579 For comparison if the capacity would not be preserved the internal buffer would then result in
5580 <code>|1|2|5|6|7|8|9|3|4|</code>.
5588 <code><a href="#classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95">insert(iterator,
5589 value_type)</a></code>, <code><a href=
5590 "#classboost_1_1circular__buffer_1b2f197c99d47138db777f0a46783b140">insert(iterator, size_type,
5591 value_type)</a></code>, <code><a href=
5592 "#classboost_1_1circular__buffer_12c9332f457bf5bb3128463cf528c058c">rinsert(iterator,
5593 value_type)</a></code>, <code><a href=
5594 "#classboost_1_1circular__buffer_1a47a5358db1b7d7e4925c16db13d2fc5">rinsert(iterator, size_type,
5595 value_type)</a></code>, <code><a href=
5596 "#classboost_1_1circular__buffer_1d6479cbc43a304bdbf04262f957fa323">rinsert(iterator, InputIterator,
5597 InputIterator)</a></code>
5604 <a id="classboost_1_1circular__buffer_12c9332f457bf5bb3128463cf528c058c" name=
5605 "classboost_1_1circular__buffer_12c9332f457bf5bb3128463cf528c058c"></a><code><b><a href=
5606 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> rinsert(<a href=
5607 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> pos, <a href=
5608 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a> item =
5609 value_type());</b></code><br>
5611 Insert an element before the specified position.
5614 <b>Precondition:</b>
5617 <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end.
5625 The <code>item</code> will be inserted before the position <code>pos</code>.<br>
5626 If the <code>circular_buffer</code> is full, the last element will be overwritten. If the
5627 <code>circular_buffer</code> is full and the <code>pos</code> points to <code><a href=
5628 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>, then the
5629 <code>item</code> will not be inserted. If the capacity is <code>0</code>, nothing will be inserted.
5634 <b>Parameter(s):</b>
5642 An iterator specifying the position before which the <code>item</code> will be inserted.
5652 The element to be inserted.
5662 Iterator to the inserted element or <code><a href=
5663 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code> if the
5664 <code>item</code> is not inserted. (See the <i>Effect</i>.)
5672 Whatever <code>T::T(const T&)</code> throws.
5675 Whatever <code>T::operator = (const T&)</code> throws.
5680 <b>Exception Safety:</b>
5683 Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything.
5688 <b>Iterator Invalidation:</b>
5691 Invalidates iterators pointing to the elements before the insertion point (towards the beginning and
5692 excluding <code>pos</code>). It also invalidates iterators pointing to the overwritten element.
5700 Linear (in <code>std::distance(<a href=
5701 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, pos)</code>).
5709 <code><a href="#classboost_1_1circular__buffer_1a47a5358db1b7d7e4925c16db13d2fc5">rinsert(iterator,
5710 size_type, value_type)</a></code>, <code><a href=
5711 "#classboost_1_1circular__buffer_1d6479cbc43a304bdbf04262f957fa323">rinsert(iterator, InputIterator,
5712 InputIterator)</a></code>, <code><a href=
5713 "#classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95">insert(iterator,
5714 value_type)</a></code>, <code><a href=
5715 "#classboost_1_1circular__buffer_1b2f197c99d47138db777f0a46783b140">insert(iterator, size_type,
5716 value_type)</a></code>, <code><a href=
5717 "#classboost_1_1circular__buffer_1d00091d1d794cab3264b3674e99b33f6">insert(iterator, InputIterator,
5718 InputIterator)</a></code>
5725 <a id="classboost_1_1circular__buffer_1a47a5358db1b7d7e4925c16db13d2fc5" name=
5726 "classboost_1_1circular__buffer_1a47a5358db1b7d7e4925c16db13d2fc5"></a><code><b>void rinsert(<a href=
5727 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> pos, <a href=
5728 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n, <a href=
5729 "#classboost_1_1circular__buffer_1a8397191092f5bacee991b623ca4b910">const_reference</a>
5730 item);</b></code><br>
5732 Insert <code>n</code> copies of the <code>item</code> before the specified position.
5735 <b>Precondition:</b>
5738 <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end.
5746 The number of <code>min[n, (<a href=
5747 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a> - pos) + <a href=
5748 "#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a>]</code> elements will
5749 be inserted before the position <code>pos</code>.<br>
5750 The number of <code>min[<a href=
5751 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a> - pos, max[0, n -
5752 <a href="#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a>]]</code>
5753 elements will be overwritten at the end of the <code>circular_buffer</code>.<br>
5754 (See <i>Example</i> for the explanation.)
5759 <b>Parameter(s):</b>
5767 An iterator specifying the position where the <code>item</code>s will be inserted.
5777 The number of <code>item</code>s the to be inserted.
5787 The element whose copies will be inserted.
5797 Whatever <code>T::T(const T&)</code> throws.
5800 Whatever <code>T::operator = (const T&)</code> throws.
5805 <b>Exception Safety:</b>
5808 Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything.
5813 <b>Iterator Invalidation:</b>
5816 Invalidates iterators pointing to the elements before the insertion point (towards the beginning and
5817 excluding <code>pos</code>). It also invalidates iterators pointing to the overwritten elements.
5825 Linear (in <code>min[<a href=
5826 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a>,
5827 std::distance(<a href="#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>,
5836 Consider a <code>circular_buffer</code> with the capacity of 6 and the size of 4. Its internal buffer
5837 may look like the one below.<br>
5839 <code>|1|2|3|4| | |</code><br>
5840 <code>p ---^</code><br>
5842 After inserting 5 elements before the position <code>p</code>:<br>
5844 <code>rinsert(p, (size_t)5, 0);</code><br>
5846 actually only 4 elements get inserted and elements <code>3</code> and <code>4</code> are overwritten.
5847 This is due to the fact the rinsert operation preserves the capacity. After insertion the internal
5848 buffer looks like this:<br>
5850 <code>|1|2|0|0|0|0|</code><br>
5852 For comparison if the capacity would not be preserved the internal buffer would then result in
5853 <code>|1|2|0|0|0|0|0|3|4|</code>.
5861 <code><a href="#classboost_1_1circular__buffer_12c9332f457bf5bb3128463cf528c058c">rinsert(iterator,
5862 value_type)</a></code>, <code><a href=
5863 "#classboost_1_1circular__buffer_1d6479cbc43a304bdbf04262f957fa323">rinsert(iterator, InputIterator,
5864 InputIterator)</a></code>, <code><a href=
5865 "#classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95">insert(iterator,
5866 value_type)</a></code>, <code><a href=
5867 "#classboost_1_1circular__buffer_1b2f197c99d47138db777f0a46783b140">insert(iterator, size_type,
5868 value_type)</a></code>, <code><a href=
5869 "#classboost_1_1circular__buffer_1d00091d1d794cab3264b3674e99b33f6">insert(iterator, InputIterator,
5870 InputIterator)</a></code>
5877 <a id="classboost_1_1circular__buffer_1d6479cbc43a304bdbf04262f957fa323" name=
5878 "classboost_1_1circular__buffer_1d6479cbc43a304bdbf04262f957fa323"></a> <code><b>template <class
5879 InputIterator><br>
5880 void rinsert(<a href="#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a>
5881 pos, InputIterator first, InputIterator last);</b></code><br>
5883 Insert the range <code>[first, last)</code> before the specified position.
5886 <b>Precondition:</b>
5889 <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> or its end.<br>
5890 Valid range <code>[first, last)</code> where <code>first</code> and <code>last</code> meet the
5891 requirements of an <a href="http://www.sgi.com/tech/stl/InputIterator.html">InputIterator</a>.
5899 Elements from the range <code>[first, last - max[0, distance(first, last) - (<a href=
5900 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a> - pos) - <a href=
5901 "#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a>])</code> will be
5902 inserted before the position <code>pos</code>.<br>
5903 The number of <code>min[<a href=
5904 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a> - pos, max[0,
5905 distance(first, last) - <a href=
5906 "#classboost_1_1circular__buffer_10a02c4fbc53385e98569e810be9843de">reserve()</a>]]</code> elements
5907 will be overwritten at the end of the <code>circular_buffer</code>.<br>
5908 (See <i>Example</i> for the explanation.)
5913 <b>Parameter(s):</b>
5921 An iterator specifying the position where the range will be inserted.
5931 The beginning of the range to be inserted.
5941 The end of the range to be inserted.
5951 Whatever <code>T::T(const T&)</code> throws.
5954 Whatever <code>T::operator = (const T&)</code> throws.
5959 <b>Exception Safety:</b>
5962 Basic; no-throw if the operations in the <i>Throws</i> section do not throw anything.
5967 <b>Iterator Invalidation:</b>
5970 Invalidates iterators pointing to the elements before the insertion point (towards the beginning and
5971 excluding <code>pos</code>). It also invalidates iterators pointing to the overwritten elements.
5979 Linear (in <code>[std::distance(<a href=
5980 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, pos) +
5981 std::distance(first, last)]</code>; in <code>min[<a href=
5982 "#classboost_1_1circular__buffer_15ebab2b2538d733790b5752582728e77">capacity()</a>,
5983 std::distance(<a href="#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>,
5984 pos) + std::distance(first, last)]</code> if the <code>InputIterator</code> is a <a href=
5985 "http://www.sgi.com/tech/stl/RandomAccessIterator.html">RandomAccessIterator</a>).
5993 Consider a <code>circular_buffer</code> with the capacity of 6 and the size of 4. Its internal buffer
5994 may look like the one below.<br>
5996 <code>|1|2|3|4| | |</code><br>
5997 <code>p ---^</code><br>
5999 After inserting a range of elements before the position <code>p</code>:<br>
6001 <code>int array[] = { 5, 6, 7, 8, 9 };</code><br>
6002 <code>insert(p, array, array + 5);</code><br>
6004 actually only elements <code>5</code>, <code>6</code>, <code>7</code> and <code>8</code> from the
6005 specified range get inserted and elements <code>3</code> and <code>4</code> are overwritten. This is
6006 due to the fact the rinsert operation preserves the capacity. After insertion the internal buffer looks
6009 <code>|1|2|5|6|7|8|</code><br>
6011 For comparison if the capacity would not be preserved the internal buffer would then result in
6012 <code>|1|2|5|6|7|8|9|3|4|</code>.
6020 <code><a href="#classboost_1_1circular__buffer_12c9332f457bf5bb3128463cf528c058c">rinsert(iterator,
6021 value_type)</a></code>, <code><a href=
6022 "#classboost_1_1circular__buffer_1a47a5358db1b7d7e4925c16db13d2fc5">rinsert(iterator, size_type,
6023 value_type)</a></code>, <code><a href=
6024 "#classboost_1_1circular__buffer_128c92740fee1b9deb8c69816e389de95">insert(iterator,
6025 value_type)</a></code>, <code><a href=
6026 "#classboost_1_1circular__buffer_1b2f197c99d47138db777f0a46783b140">insert(iterator, size_type,
6027 value_type)</a></code>, <code><a href=
6028 "#classboost_1_1circular__buffer_1d00091d1d794cab3264b3674e99b33f6">insert(iterator, InputIterator,
6029 InputIterator)</a></code>
6036 <a id="classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3" name=
6037 "classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3"></a><code><b><a href=
6038 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> erase(<a href=
6039 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> pos);</b></code><br>
6041 Remove an element at the specified position.
6044 <b>Precondition:</b>
6047 <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> (but not an
6048 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
6056 The element at the position <code>pos</code> is removed.
6061 <b>Parameter(s):</b>
6069 An iterator pointing at the element to be removed.
6079 Iterator to the first element remaining beyond the removed element or <code><a href=
6080 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code> if no such element
6089 Whatever <code>T::operator = (const T&)</code> throws.
6094 <b>Exception Safety:</b>
6097 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
6102 <b>Iterator Invalidation:</b>
6105 Invalidates iterators pointing to the erased element and iterators pointing to the elements behind the
6106 erased element (towards the end; except iterators equal to <code><a href=
6107 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
6115 Linear (in <code>std::distance(pos, <a href=
6116 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>)</code>).
6124 <code><a href="#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(iterator,
6125 iterator)</a></code>, <code><a href=
6126 "#classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f">rerase(iterator)</a></code>,
6127 <code><a href="#classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f">rerase(iterator,
6128 iterator)</a></code>, <code><a href=
6129 "#classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd">erase_begin(size_type)</a></code>,
6131 "#classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7">erase_end(size_type)</a></code>,
6132 <code><a href="#classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e">clear()</a></code>
6139 <a id="classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd" name=
6140 "classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd"></a><code><b><a href=
6141 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> erase(<a href=
6142 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> first, <a href=
6143 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> last);</b></code><br>
6145 Erase the range <code>[first, last)</code>.
6148 <b>Precondition:</b>
6151 Valid range <code>[first, last)</code>.
6159 The elements from the range <code>[first, last)</code> are removed. (If <code>first == last</code>
6160 nothing is removed.)
6165 <b>Parameter(s):</b>
6173 The beginning of the range to be removed.
6183 The end of the range to be removed.
6193 Iterator to the first element remaining beyond the removed elements or <code><a href=
6194 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code> if no such element
6203 Whatever <code>T::operator = (const T&)</code> throws.
6208 <b>Exception Safety:</b>
6211 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
6216 <b>Iterator Invalidation:</b>
6219 Invalidates iterators pointing to the erased elements and iterators pointing to the elements behind the
6220 erased range (towards the end; except iterators equal to <code><a href=
6221 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
6229 Linear (in <code>std::distance(first, <a href=
6230 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>)</code>).
6239 "#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase(iterator)</a></code>,
6241 "#classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f">rerase(iterator)</a></code>,
6242 <code><a href="#classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f">rerase(iterator,
6243 iterator)</a></code>, <code><a href=
6244 "#classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd">erase_begin(size_type)</a></code>,
6246 "#classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7">erase_end(size_type)</a></code>,
6247 <code><a href="#classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e">clear()</a></code>
6254 <a id="classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f" name=
6255 "classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f"></a><code><b><a href=
6256 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> rerase(<a href=
6257 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> pos);</b></code><br>
6259 Remove an element at the specified position.
6262 <b>Precondition:</b>
6265 <code>pos</code> is a valid iterator pointing to the <code>circular_buffer</code> (but not an
6266 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
6274 The element at the position <code>pos</code> is removed.
6279 <b>Parameter(s):</b>
6287 An iterator pointing at the element to be removed.
6297 Iterator to the first element remaining in front of the removed element or <code><a href=
6298 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code> if no such
6307 Whatever <code>T::operator = (const T&)</code> throws.
6312 <b>Exception Safety:</b>
6315 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
6320 <b>Iterator Invalidation:</b>
6323 Invalidates iterators pointing to the erased element and iterators pointing to the elements in front of
6324 the erased element (towards the beginning).
6332 Linear (in <code>std::distance(<a href=
6333 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, pos)</code>).
6341 This method is symetric to the <code><a href=
6342 "#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase(iterator)</a></code> method
6343 and is more effective than <code><a href=
6344 "#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase(iterator)</a></code> if the
6345 iterator <code>pos</code> is close to the beginning of the <code>circular_buffer</code>. (See the
6355 "#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase(iterator)</a></code>,
6356 <code><a href="#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(iterator,
6357 iterator)</a></code>, <code><a href=
6358 "#classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f">rerase(iterator,
6359 iterator)</a></code>, <code><a href=
6360 "#classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd">erase_begin(size_type)</a></code>,
6362 "#classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7">erase_end(size_type)</a></code>,
6363 <code><a href="#classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e">clear()</a></code>
6370 <a id="classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f" name=
6371 "classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f"></a><code><b><a href=
6372 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> rerase(<a href=
6373 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> first, <a href=
6374 "#classboost_1_1circular__buffer_11b8a33f2dc8519b8a7d344ed4408c532">iterator</a> last);</b></code><br>
6376 Erase the range <code>[first, last)</code>.
6379 <b>Precondition:</b>
6382 Valid range <code>[first, last)</code>.
6390 The elements from the range <code>[first, last)</code> are removed. (If <code>first == last</code>
6391 nothing is removed.)
6396 <b>Parameter(s):</b>
6404 The beginning of the range to be removed.
6414 The end of the range to be removed.
6424 Iterator to the first element remaining in front of the removed elements or <code><a href=
6425 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a></code> if no such
6434 Whatever <code>T::operator = (const T&)</code> throws.
6439 <b>Exception Safety:</b>
6442 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything.
6447 <b>Iterator Invalidation:</b>
6450 Invalidates iterators pointing to the erased elements and iterators pointing to the elements in front
6451 of the erased range (towards the beginning).
6459 Linear (in <code>std::distance(<a href=
6460 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, last)</code>).
6468 This method is symetric to the <code><a href=
6469 "#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(iterator,
6470 iterator)</a></code> method and is more effective than <code><a href=
6471 "#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(iterator,
6472 iterator)</a></code> if <code>std::distance(<a href=
6473 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, first)</code> is lower
6474 that <code>std::distance(last, <a href=
6475 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>)</code>.
6484 "#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase(iterator)</a></code>,
6485 <code><a href="#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(iterator,
6486 iterator)</a></code>, <code><a href=
6487 "#classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f">rerase(iterator)</a></code>,
6489 "#classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd">erase_begin(size_type)</a></code>,
6491 "#classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7">erase_end(size_type)</a></code>,
6492 <code><a href="#classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e">clear()</a></code>
6499 <a id="classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd" name=
6500 "classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd"></a><code><b>void erase_begin(<a href=
6501 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n);</b></code><br>
6503 Remove first <code>n</code> elements (with constant complexity for scalar types).
6506 <b>Precondition:</b>
6509 <code>n <= <a href=
6510 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>
6518 The <code>n</code> elements at the beginning of the <code>circular_buffer</code> will be removed.
6523 <b>Parameter(s):</b>
6531 The number of elements to be removed.
6541 Whatever <code>T::operator = (const T&)</code> throws. (Does not throw anything in case of
6547 <b>Exception Safety:</b>
6550 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. (I.e. no throw
6551 in case of scalars.)
6556 <b>Iterator Invalidation:</b>
6559 Invalidates iterators pointing to the first <code>n</code> erased elements.
6567 Constant (in <code>n</code>) for scalar types; linear for other types.
6575 This method has been specially designed for types which do not require an explicit destructruction
6576 (e.g. integer, float or a pointer). For these scalar types a call to a destructor is not required which
6577 makes it possible to implement the "erase from beginning" operation with a constant complexity. For
6578 non-sacalar types the complexity is linear (hence the explicit destruction is needed) and the
6579 implementation is actually equivalent to <code><a href=
6580 "#classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f">rerase(begin(), begin() +
6590 "#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase(iterator)</a></code>,
6591 <code><a href="#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(iterator,
6592 iterator)</a></code>, <code><a href=
6593 "#classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f">rerase(iterator)</a></code>,
6594 <code><a href="#classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f">rerase(iterator,
6595 iterator)</a></code>, <code><a href=
6596 "#classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7">erase_end(size_type)</a></code>,
6597 <code><a href="#classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e">clear()</a></code>
6604 <a id="classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7" name=
6605 "classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7"></a><code><b>void erase_end(<a href=
6606 "#classboost_1_1circular__buffer_19ba12c0142a21a7d960877c22fa3ea00">size_type</a> n);</b></code><br>
6608 Remove last <code>n</code> elements (with constant complexity for scalar types).
6611 <b>Precondition:</b>
6614 <code>n <= <a href=
6615 "#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a></code>
6623 The <code>n</code> elements at the end of the <code>circular_buffer</code> will be removed.
6628 <b>Parameter(s):</b>
6636 The number of elements to be removed.
6646 Whatever <code>T::operator = (const T&)</code> throws. (Does not throw anything in case of
6652 <b>Exception Safety:</b>
6655 Basic; no-throw if the operation in the <i>Throws</i> section does not throw anything. (I.e. no throw
6656 in case of scalars.)
6661 <b>Iterator Invalidation:</b>
6664 Invalidates iterators pointing to the last <code>n</code> erased elements.
6672 Constant (in <code>n</code>) for scalar types; linear for other types.
6680 This method has been specially designed for types which do not require an explicit destructruction
6681 (e.g. integer, float or a pointer). For these scalar types a call to a destructor is not required which
6682 makes it possible to implement the "erase from end" operation with a constant complexity. For
6683 non-sacalar types the complexity is linear (hence the explicit destruction is needed) and the
6684 implementation is actually equivalent to <code><a href=
6685 "#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(end() - n, end())</a></code>.
6694 "#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase(iterator)</a></code>,
6695 <code><a href="#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(iterator,
6696 iterator)</a></code>, <code><a href=
6697 "#classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f">rerase(iterator)</a></code>,
6698 <code><a href="#classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f">rerase(iterator,
6699 iterator)</a></code>, <code><a href=
6700 "#classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd">erase_begin(size_type)</a></code>,
6701 <code><a href="#classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e">clear()</a></code>
6708 <a id="classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e" name=
6709 "classboost_1_1circular__buffer_1826f5770a40b8b752eb9587378464d1e"></a><code><b>void
6710 clear();</b></code><br>
6712 Remove all stored elements from the <code>circular_buffer</code>.
6718 <code><a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
6732 <b>Exception Safety:</b>
6740 <b>Iterator Invalidation:</b>
6743 Invalidates all iterators pointing to the <code>circular_buffer</code> (except iterators equal to
6744 <code><a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a></code>).
6752 Constant (in the size of the <code>circular_buffer</code>) for scalar types; linear for other types.
6761 "#classboost_1_1circular__buffer_164250ffbbbdbc62b99e8301fc195b80c">~circular_buffer()</a></code>,
6763 "#classboost_1_1circular__buffer_197155de712db1759e1698455b49a0be3">erase(iterator)</a></code>,
6764 <code><a href="#classboost_1_1circular__buffer_1a96415389509a18bd7d7b5d8e4dda9bd">erase(iterator,
6765 iterator)</a></code>, <code><a href=
6766 "#classboost_1_1circular__buffer_1b6d4ae77d7445f844e30e78592f1e06f">rerase(iterator)</a></code>,
6767 <code><a href="#classboost_1_1circular__buffer_1b0f98ae303584ded5397f067bbfc911f">rerase(iterator,
6768 iterator)</a></code>, <code><a href=
6769 "#classboost_1_1circular__buffer_1b25d379cf66ace025036a47ddb344abd">erase_begin(size_type)</a></code>,
6771 "#classboost_1_1circular__buffer_17485ee7f58b01363170114f2123a48d7">erase_end(size_type)</a></code>
6779 <a name="functions" id="functions">Standalone Functions</a>
6781 <div id="srcdoc_functions">
6782 <table id="table_functions" border="1" cellpadding="3">
6785 <a id="namespaceboost_1d35871e838359b5215e1cbb353663207" name=
6786 "namespaceboost_1d35871e838359b5215e1cbb353663207"></a> <code><b>template <class T, class Alloc><br>
6787 bool operator==(const circular_buffer<T,Alloc>& lhs, const
6788 circular_buffer<T,Alloc>& rhs);</b></code><br>
6790 Compare two <code>circular_buffer</code>s element-by-element to determine if they are equal.
6793 <b>Parameter(s):</b>
6801 The <code>circular_buffer</code> to compare.
6811 The <code>circular_buffer</code> to compare.
6821 <code>lhs.<a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> ==
6822 rhs.<a href="#classboost_1_1circular__buffer_15fa0edd153e2591dd6bf070eb663ee32">size()</a> &&
6823 <a href="http://www.sgi.com/tech/stl/equal.html">std::equal</a>(lhs.<a href=
6824 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, lhs.<a href=
6825 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>, rhs.<a href=
6826 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>)</code>
6842 Linear (in the size of the <code>circular_buffer</code>s).
6847 <b>Iterator Invalidation:</b>
6850 Does not invalidate any iterators.
6857 <a id="namespaceboost_195b08213f201c2067d8acb024756329d" name=
6858 "namespaceboost_195b08213f201c2067d8acb024756329d"></a> <code><b>template <class T, class Alloc><br>
6859 bool operator<(const circular_buffer<T,Alloc>& lhs, const
6860 circular_buffer<T,Alloc>& rhs);</b></code><br>
6862 Compare two <code>circular_buffer</code>s element-by-element to determine if the left one is lesser than
6866 <b>Parameter(s):</b>
6874 The <code>circular_buffer</code> to compare.
6884 The <code>circular_buffer</code> to compare.
6895 "http://www.sgi.com/tech/stl/lexicographical_compare.html">std::lexicographical_compare</a>(lhs.<a href="#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>,
6896 lhs.<a href="#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>, rhs.<a href=
6897 "#classboost_1_1circular__buffer_158d1ede2e85f5d46eda8db3f0c4efef0">begin()</a>, rhs.<a href=
6898 "#classboost_1_1circular__buffer_1babfa093dad7801223b80626b598dee1">end()</a>)</code>
6914 Linear (in the size of the <code>circular_buffer</code>s).
6919 <b>Iterator Invalidation:</b>
6922 Does not invalidate any iterators.
6929 <a id="namespaceboost_1f5717e2f6532581a6492ff1839b18f6d" name=
6930 "namespaceboost_1f5717e2f6532581a6492ff1839b18f6d"></a> <code><b>template <class T, class Alloc><br>
6931 bool operator!=(const circular_buffer<T,Alloc>& lhs, const
6932 circular_buffer<T,Alloc>& rhs);</b></code><br>
6934 Compare two <code>circular_buffer</code>s element-by-element to determine if they are non-equal.
6937 <b>Parameter(s):</b>
6945 The <code>circular_buffer</code> to compare.
6955 The <code>circular_buffer</code> to compare.
6965 <code>!(lhs == rhs)</code>
6981 Linear (in the size of the <code>circular_buffer</code>s).
6986 <b>Iterator Invalidation:</b>
6989 Does not invalidate any iterators.
6997 <code><a href="#namespaceboost_1d35871e838359b5215e1cbb353663207">operator==(const
6998 circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&)</a></code>
7005 <a id="namespaceboost_1f575d7a9741c2044424de50c966c12f3" name=
7006 "namespaceboost_1f575d7a9741c2044424de50c966c12f3"></a> <code><b>template <class T, class Alloc><br>
7007 bool operator>(const circular_buffer<T,Alloc>& lhs, const
7008 circular_buffer<T,Alloc>& rhs);</b></code><br>
7010 Compare two <code>circular_buffer</code>s element-by-element to determine if the left one is greater than
7014 <b>Parameter(s):</b>
7022 The <code>circular_buffer</code> to compare.
7032 The <code>circular_buffer</code> to compare.
7042 <code>rhs < lhs</code>
7058 Linear (in the size of the <code>circular_buffer</code>s).
7063 <b>Iterator Invalidation:</b>
7066 Does not invalidate any iterators.
7074 <code><a href="#namespaceboost_195b08213f201c2067d8acb024756329d">operator<(const
7075 circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&)</a></code>
7082 <a id="namespaceboost_179abcbacd24b67f08185db54aec8600d" name=
7083 "namespaceboost_179abcbacd24b67f08185db54aec8600d"></a> <code><b>template <class T, class Alloc><br>
7084 bool operator<=(const circular_buffer<T,Alloc>& lhs, const
7085 circular_buffer<T,Alloc>& rhs);</b></code><br>
7087 Compare two <code>circular_buffer</code>s element-by-element to determine if the left one is lesser or
7088 equal to the right one.
7091 <b>Parameter(s):</b>
7099 The <code>circular_buffer</code> to compare.
7109 The <code>circular_buffer</code> to compare.
7119 <code>!(rhs < lhs)</code>
7135 Linear (in the size of the <code>circular_buffer</code>s).
7140 <b>Iterator Invalidation:</b>
7143 Does not invalidate any iterators.
7151 <code><a href="#namespaceboost_195b08213f201c2067d8acb024756329d">operator<(const
7152 circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&)</a></code>
7159 <a id="namespaceboost_11c31150380272af67deebef578c80b05" name=
7160 "namespaceboost_11c31150380272af67deebef578c80b05"></a> <code><b>template <class T, class Alloc><br>
7161 bool operator>=(const circular_buffer<T,Alloc>& lhs, const
7162 circular_buffer<T,Alloc>& rhs);</b></code><br>
7164 Compare two <code>circular_buffer</code>s element-by-element to determine if the left one is greater or
7165 equal to the right one.
7168 <b>Parameter(s):</b>
7176 The <code>circular_buffer</code> to compare.
7186 The <code>circular_buffer</code> to compare.
7196 <code>!(lhs < rhs)</code>
7212 Linear (in the size of the <code>circular_buffer</code>s).
7217 <b>Iterator Invalidation:</b>
7220 Does not invalidate any iterators.
7228 <code><a href="#namespaceboost_195b08213f201c2067d8acb024756329d">operator<(const
7229 circular_buffer<T,Alloc>&, const circular_buffer<T,Alloc>&)</a></code>
7236 <a id="namespaceboost_14aa8f6a2c9640f3f22e266f0fca85777" name=
7237 "namespaceboost_14aa8f6a2c9640f3f22e266f0fca85777"></a> <code><b>template <class T, class Alloc><br>
7238 void swap(circular_buffer<T,Alloc>& lhs, circular_buffer<T,Alloc>&
7239 rhs);</b></code><br>
7241 Swap the contents of two <code>circular_buffer</code>s.
7247 <code>lhs</code> contains elements of <code>rhs</code> and vice versa.
7252 <b>Parameter(s):</b>
7260 The <code>circular_buffer</code> whose content will be swapped with <code>rhs</code>.
7270 The <code>circular_buffer</code> whose content will be swapped with <code>lhs</code>.
7288 Constant (in the size of the <code>circular_buffer</code>s).
7293 <b>Iterator Invalidation:</b>
7296 Invalidates all iterators of both <code>circular_buffer</code>s. (On the other hand the iterators still
7297 point to the same elements but within another container. If you want to rely on this feature you have
7298 to turn the <a href="#debug">Debug Support</a> off otherwise an assertion will report an error if such
7299 invalidated iterator is used.)
7308 "#classboost_1_1circular__buffer_1270ab7074c365663a6f18808024fd88b">swap(circular_buffer<T,
7309 Alloc>&)</a></code>
7317 <a name="notes" id="notes">Notes</a>
7321 <a name="note1" id="note1"></a>
7323 A good implementation of smart pointers is included in <a href="../../smart_ptr/">Boost</a>.
7327 <a name="note2" id="note2"></a>
7329 Never create a circular buffer of <code>std::auto_ptr</code>. Refer to <a href=
7330 "http://www.aristeia.com">Scott Meyers</a> ' excellent book <em>Effective STL</em> for a detailed discussion.
7331 (Meyers S., <i>Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library</i>.
7332 Addison-Wesley, 2001.)
7337 <a name="see" id="see">See also</a>
7340 <code><a href="space_optimized.html">boost::circular_buffer_space_optimized</a>, <a href=
7341 "http://www.sgi.com/tech/stl/Vector.html">std::vector</a>, <a href=
7342 "http://www.sgi.com/tech/stl/List.html">std::list</a>, <a href=
7343 "http://www.sgi.com/tech/stl/Deque.html">std::deque</a></code>
7346 <a name="ack" id="ack">Acknowledgements</a>
7349 The <code>circular_buffer</code> has a short history. Its first version was a <code>std::deque</code> adaptor.
7350 This container was not very effective because of many reallocations when inserting/removing an element. Thomas
7351 Wenish did a review of this version and motivated me to create a circular buffer which allocates memory at once
7355 The second version adapted <code>std::vector</code> but it has been abandoned soon because of limited control
7356 over iterator invalidation.
7359 The current version is a full-fledged STL compliant container. Pavel Vozenilek did a thorough review of this
7360 version and came with many good ideas and improvements. Also, I would like to thank Howard Hinnant, Nigel Stewart
7361 and everyone who participated at the formal review for valuable comments and ideas.
7364 <a name="relnotes" id="relnotes">Release Notes</a>
7374 <li>Added methods <code>erase_begin(size_type)</code> and <code>erase_end(size_type)</code> with constant
7375 complexity for such types of stored elements which do not need an explicit destruction e.g. <code>int</code>
7376 or <code>double</code>.
7378 <li>Similarly changed implementation of the <code>clear()</code> method and the destructor so their
7379 complexity is now constant for such types of stored elements which do not require an explicit destruction
7380 (the complexity for other types remains linear).
7391 <li>Added new methods <code>is_linearized()</code> and <code>rotate(const_iterator)</code>.
7394 #1987 Patch to make <code>circular_buffer.hpp</code> #includes absolute.<br>
7395 #1852 Copy constructor does not copy capacity.
7406 <li>Changed behaviour of the <code>circular_buffer(const allocator_type&)</code> constructor. Since this
7407 version the constructor does not allocate any memory and both capacity and size are set to zero.
7410 #1919 Default constructed circular buffer throws <code>std::bad_alloc</code>.<br>
7421 <li>Initial release.
7428 <small>Copyright © 2003-2008 Jan Gaspar</small>
7431 <small>Use, modification, and distribution is subject to the Boost Software License, Version 1.0.<br>
7432 (See accompanying file <code>LICENSE_1_0.txt</code> or copy at <a href=
7433 "http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</a>)</small>