]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/container/example/doc_emplace.cpp
import quincy beta 17.1.0
[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
11 //[doc_emplace
12 #include <boost/container/list.hpp>
13 #include <cassert>
14
15 //Non-copyable and non-movable class
16 class non_copy_movable
17 {
18 non_copy_movable(const non_copy_movable &);
19 non_copy_movable& operator=(const non_copy_movable &);
20
21 public:
22 non_copy_movable(int = 0) {}
23 };
24
25 int main ()
26 {
27 using namespace boost::container;
28
29 //Store non-copyable and non-movable objects in a list
30 list<non_copy_movable> l;
31 non_copy_movable ncm;
32
33 //A new element will be built calling non_copy_movable(int) constructor
34 l.emplace(l.begin(), 0);
35 assert(l.size() == 1);
36
37 //A new element will be value initialized
38 l.emplace(l.begin());
39 assert(l.size() == 2);
40 return 0;
41 }
42 //]