]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/circular_buffer/example/circular_buffer_iter_example.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / circular_buffer / example / circular_buffer_iter_example.cpp
1 // Copyright 2003-2008 Jan Gaspar.
2 // Copyright 2013 Paul A. Bristow. Added some Quickbook snippet markers.
3
4 // Distributed under the Boost Software License, Version 1.0.
5 // (See the accompanying file LICENSE_1_0.txt
6 // or a copy at <http://www.boost.org/LICENSE_1_0.txt>.)
7
8 #undef BOOST_CB_ENABLE_DEBUG
9
10 //[circular_buffer_iter_example_1
11 /*`
12 */
13
14 #define BOOST_CB_ENABLE_DEBUG 0 // The Debug Support has to be disabled, otherwise the code produces a runtime error.
15
16 #include <boost/circular_buffer.hpp>
17 #include <boost/assert.hpp>
18 #include <assert.h>
19
20 int main(int /*argc*/, char* /*argv*/[])
21 {
22
23 boost::circular_buffer<int> cb(3);
24
25 cb.push_back(1);
26 cb.push_back(2);
27 cb.push_back(3);
28
29 boost::circular_buffer<int>::iterator it = cb.begin();
30
31 assert(*it == 1);
32
33 cb.push_back(4);
34
35 assert(*it == 4); // The iterator still points to the initialized memory.
36
37 return 0;
38 }
39
40 //] [/circular_buffer_iter_example_1]