1 | // Boost.Range library
|
---|
2 | //
|
---|
3 | // Copyright Neil Groves 2009. Use, modification and
|
---|
4 | // distribution is subject to the Boost Software License, Version
|
---|
5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
6 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
7 | //
|
---|
8 | // For more information, see http://www.boost.org/libs/range/
|
---|
9 | //
|
---|
10 | #ifndef BOOST_RANGE_ALGORITHM_EXT_INSERT_HPP_INCLUDED
|
---|
11 | #define BOOST_RANGE_ALGORITHM_EXT_INSERT_HPP_INCLUDED
|
---|
12 |
|
---|
13 | #include <boost/range/config.hpp>
|
---|
14 | #include <boost/range/concepts.hpp>
|
---|
15 | #include <boost/range/difference_type.hpp>
|
---|
16 | #include <boost/range/begin.hpp>
|
---|
17 | #include <boost/range/end.hpp>
|
---|
18 | #include <boost/assert.hpp>
|
---|
19 |
|
---|
20 | namespace boost
|
---|
21 | {
|
---|
22 | namespace range
|
---|
23 | {
|
---|
24 |
|
---|
25 | template< class Container, class Range >
|
---|
26 | inline Container& insert( Container& on,
|
---|
27 | BOOST_DEDUCED_TYPENAME Container::iterator before,
|
---|
28 | const Range& from )
|
---|
29 | {
|
---|
30 | BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
|
---|
31 | BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
|
---|
32 | BOOST_ASSERT( (void*)&on != (void*)&from &&
|
---|
33 | "cannot copy from a container to itself" );
|
---|
34 | on.insert( before, boost::begin(from), boost::end(from) );
|
---|
35 | return on;
|
---|
36 | }
|
---|
37 |
|
---|
38 | // for associative containers
|
---|
39 | template< class Container, class Range >
|
---|
40 | inline Container& insert( Container& on,
|
---|
41 | const Range& from )
|
---|
42 | {
|
---|
43 | BOOST_RANGE_CONCEPT_ASSERT(( ForwardRangeConcept<Container> ));
|
---|
44 | BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Range> ));
|
---|
45 | BOOST_ASSERT( (void*)&on != (void*)&from &&
|
---|
46 | "cannot copy from a container to itself" );
|
---|
47 | on.insert( boost::begin(from), boost::end(from) );
|
---|
48 | return on;
|
---|
49 | }
|
---|
50 |
|
---|
51 | } // namespace range
|
---|
52 | using range::insert;
|
---|
53 | } // namespace boost
|
---|
54 |
|
---|
55 | #endif // include guard
|
---|