]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/container/example/doc_emplace.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / container / example / doc_emplace.cpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2009-2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://www.boost.org/libs/container for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10 #include <boost/container/detail/config_begin.hpp>
11 #include <boost/container/detail/workaround.hpp>
12 //[doc_emplace
13 #include <boost/container/list.hpp>
14 #include <cassert>
15
16 //Non-copyable and non-movable class
17 class non_copy_movable
18 {
19 non_copy_movable(const non_copy_movable &);
20 non_copy_movable& operator=(const non_copy_movable &);
21
22 public:
23 non_copy_movable(int = 0) {}
24 };
25
26 int main ()
27 {
28 using namespace boost::container;
29
30 //Store non-copyable and non-movable objects in a list
31 list<non_copy_movable> l;
32 non_copy_movable ncm;
33
34 //A new element will be built calling non_copy_movable(int) contructor
35 l.emplace(l.begin(), 0);
36 assert(l.size() == 1);
37
38 //A new element will be value initialized
39 l.emplace(l.begin());
40 assert(l.size() == 2);
41 return 0;
42 }
43 //]
44 #include <boost/container/detail/config_end.hpp>