blob: c71541245c7c729bbc9899a6046cd9f3e6c8180a [file] [log] [blame]
Brian Silverman1f5d3982018-08-04 23:37:52 -07001//////////////////////////////////////////////////////////////////////////////
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//////////////////////////////////////////////////////////////////////////////
11
12#include <boost/move/detail/config_begin.hpp>
13
14//[move_inserter_example
15#include <boost/container/list.hpp>
16#include "movable.hpp"
17#include <cassert>
18#include <algorithm>
19
20using namespace ::boost::container;
21
22typedef list<movable> list_t;
23typedef list_t::iterator l_iterator;
24
25template<class MoveInsertIterator>
26void test_move_inserter(list_t &l2, MoveInsertIterator mit)
27{
28 //Create a list with 10 default constructed objects
29 list<movable> l(10);
30 assert(!l.begin()->moved());
31 l2.clear();
32
33 //Move insert into l2 containers
34 std::copy(l.begin(), l.end(), mit);
35
36 //Check size and status
37 assert(l2.size() == l.size());
38 assert(l.begin()->moved());
39 assert(!l2.begin()->moved());
40}
41
42int main()
43{
44 list_t l2;
45 test_move_inserter(l2, boost::back_move_inserter(l2));
46 test_move_inserter(l2, boost::front_move_inserter(l2));
47 test_move_inserter(l2, boost::move_inserter(l2, l2.end()));
48 return 0;
49}
50//]
51
52#include <boost/move/detail/config_end.hpp>