]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/range/include/boost/range/algorithm_ext/overwrite.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / range / include / boost / range / algorithm_ext / overwrite.hpp
CommitLineData
7c673cae
FG
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_OVERWRITE_HPP_INCLUDED
11#define BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_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/iterator.hpp>
17#include <boost/range/begin.hpp>
18#include <boost/range/end.hpp>
19#include <boost/assert.hpp>
20
21namespace boost
22{
23 namespace range
24 {
25
26template< class SinglePassRange1, class SinglePassRange2 >
27inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to )
28{
29 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
30 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
31
32 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
33 i = boost::begin(from), e = boost::end(from);
34
35 BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
36 out = boost::begin(to);
37
38#ifndef NDEBUG
39 BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
40 last_out = boost::end(to);
41#endif
42
43 for( ; i != e; ++out, ++i )
44 {
45#ifndef NDEBUG
46 BOOST_ASSERT( out != last_out
47 && "out of bounds in boost::overwrite()" );
48#endif
49 *out = *i;
50 }
51}
52
53template< class SinglePassRange1, class SinglePassRange2 >
54inline void overwrite( const SinglePassRange1& from, const SinglePassRange2& to )
55{
56 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
57 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
58
59 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
60 i = boost::begin(from), e = boost::end(from);
61
62 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type
63 out = boost::begin(to);
64
65#ifndef NDEBUG
66 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type
67 last_out = boost::end(to);
68#endif
69
70 for( ; i != e; ++out, ++i )
71 {
72#ifndef NDEBUG
73 BOOST_ASSERT( out != last_out
74 && "out of bounds in boost::overwrite()" );
75#endif
76 *out = *i;
77 }
78}
79
80 } // namespace range
81 using range::overwrite;
82} // namespace boost
83
84#endif // include guard