File indexing completed on 2025-01-18 09:51:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED
0011 #define BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED
0012
0013 #include <boost/range/config.hpp>
0014 #include <boost/range/concepts.hpp>
0015 #include <boost/range/difference_type.hpp>
0016 #include <boost/range/iterator.hpp>
0017 #include <boost/range/begin.hpp>
0018 #include <boost/range/end.hpp>
0019 #include <boost/assert.hpp>
0020
0021 namespace boost
0022 {
0023 namespace range
0024 {
0025
0026 template< class SinglePassRange1, class SinglePassRange2 >
0027 inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to )
0028 {
0029 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0030 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
0031
0032 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
0033 i = boost::begin(from), e = boost::end(from);
0034
0035 BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
0036 out = boost::begin(to);
0037
0038 #ifndef NDEBUG
0039 BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type
0040 last_out = boost::end(to);
0041 #endif
0042
0043 for( ; i != e; ++out, ++i )
0044 {
0045 #ifndef NDEBUG
0046 BOOST_ASSERT( out != last_out
0047 && "out of bounds in boost::overwrite()" );
0048 #endif
0049 *out = *i;
0050 }
0051 }
0052
0053 template< class SinglePassRange1, class SinglePassRange2 >
0054 inline void overwrite( const SinglePassRange1& from, const SinglePassRange2& to )
0055 {
0056 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
0057 BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
0058
0059 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type
0060 i = boost::begin(from), e = boost::end(from);
0061
0062 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type
0063 out = boost::begin(to);
0064
0065 #ifndef NDEBUG
0066 BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type
0067 last_out = boost::end(to);
0068 #endif
0069
0070 for( ; i != e; ++out, ++i )
0071 {
0072 #ifndef NDEBUG
0073 BOOST_ASSERT( out != last_out
0074 && "out of bounds in boost::overwrite()" );
0075 #endif
0076 *out = *i;
0077 }
0078 }
0079
0080 }
0081 using range::overwrite;
0082 }
0083
0084 #endif