1 //////////////////////////////////////////////////////////////////////////////
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)
7 // See http://www.boost.org/libs/container for documentation.
9 //////////////////////////////////////////////////////////////////////////////
10 #include <boost/container/detail/config_begin.hpp>
11 #include <boost/container/detail/workaround.hpp>
12 //[doc_move_containers
13 #include <boost/container/vector.hpp>
14 #include <boost/move/utility_core.hpp>
20 BOOST_MOVABLE_BUT_NOT_COPYABLE(non_copyable)
24 non_copyable(BOOST_RV_REF(non_copyable)) {}
25 non_copyable& operator=(BOOST_RV_REF(non_copyable)) { return *this; }
30 using namespace boost::container;
32 //Store non-copyable objects in a vector
33 vector<non_copyable> v;
35 v.push_back(boost::move(nc));
36 assert(v.size() == 1);
38 //Reserve no longer needs copy-constructible
40 assert(v.capacity() >= 100);
42 //This resize overload only needs movable and default constructible
44 assert(v.size() == 200);
46 //Containers are also movable
47 vector<non_copyable> v_other(boost::move(v));
48 assert(v_other.size() == 200);
54 #include <boost/container/detail/config_end.hpp>