]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/move/example/doc_move_iterator.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / move / example / doc_move_iterator.cpp
CommitLineData
7c673cae
FG
1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2009.
4// Distributed under the Boost Software License, Version 1.0.
5// (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//
8// See http://www.boost.org/libs/move for documentation.
9//
10//////////////////////////////////////////////////////////////////////////////
20effc67 11
7c673cae
FG
12//[move_iterator_example
13#include <boost/container/vector.hpp>
14#include "movable.hpp"
15#include <cassert>
16
17int main()
18{
19 using namespace ::boost::container;
20
21 //Create a vector with 10 default constructed objects
22 vector<movable> v(10);
23 assert(!v[0].moved());
24
25 //Move construct all elements in v into v2
26 vector<movable> v2( boost::make_move_iterator(v.begin())
27 , boost::make_move_iterator(v.end()));
28 assert(v[0].moved());
29 assert(!v2[0].moved());
30
31 //Now move assign all elements from in v2 back into v
32 v.assign( boost::make_move_iterator(v2.begin())
33 , boost::make_move_iterator(v2.end()));
34 assert(v2[0].moved());
35 assert(!v[0].moved());
36
37 return 0;
38}
39//]