Chris@16: // Boost.Range library Chris@16: // Chris@16: // Copyright Neil Groves 2009. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/range/ Chris@16: // Chris@16: #ifndef BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED Chris@16: #define BOOST_RANGE_ALGORITHM_EXT_OVERWRITE_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace range Chris@16: { Chris@16: Chris@16: template< class SinglePassRange1, class SinglePassRange2 > Chris@16: inline void overwrite( const SinglePassRange1& from, SinglePassRange2& to ) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); Chris@16: Chris@16: BOOST_DEDUCED_TYPENAME range_iterator::type Chris@16: i = boost::begin(from), e = boost::end(from); Chris@16: Chris@16: BOOST_DEDUCED_TYPENAME range_iterator::type Chris@16: out = boost::begin(to); Chris@16: Chris@16: #ifndef NDEBUG Chris@16: BOOST_DEDUCED_TYPENAME range_iterator::type Chris@16: last_out = boost::end(to); Chris@16: #endif Chris@16: Chris@16: for( ; i != e; ++out, ++i ) Chris@16: { Chris@16: #ifndef NDEBUG Chris@16: BOOST_ASSERT( out != last_out Chris@16: && "out of bounds in boost::overwrite()" ); Chris@16: #endif Chris@16: *out = *i; Chris@16: } Chris@16: } Chris@16: Chris@16: template< class SinglePassRange1, class SinglePassRange2 > Chris@16: inline void overwrite( const SinglePassRange1& from, const SinglePassRange2& to ) Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); Chris@16: Chris@16: BOOST_DEDUCED_TYPENAME range_iterator::type Chris@16: i = boost::begin(from), e = boost::end(from); Chris@16: Chris@16: BOOST_DEDUCED_TYPENAME range_iterator::type Chris@16: out = boost::begin(to); Chris@16: Chris@16: #ifndef NDEBUG Chris@16: BOOST_DEDUCED_TYPENAME range_iterator::type Chris@16: last_out = boost::end(to); Chris@16: #endif Chris@16: Chris@16: for( ; i != e; ++out, ++i ) Chris@16: { Chris@16: #ifndef NDEBUG Chris@16: BOOST_ASSERT( out != last_out Chris@16: && "out of bounds in boost::overwrite()" ); Chris@16: #endif Chris@16: *out = *i; Chris@16: } Chris@16: } Chris@16: Chris@16: } // namespace range Chris@16: using range::overwrite; Chris@16: } // namespace boost Chris@16: Chris@16: #endif // include guard