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_IOTA_HPP_INCLUDED Chris@16: #define BOOST_RANGE_ALGORITHM_EXT_IOTA_HPP_INCLUDED Chris@16: 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 ForwardRange, class Value > Chris@16: inline ForwardRange& iota( ForwardRange& rng, Value x ) Chris@16: { Chris@16: BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); Chris@16: typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; Chris@16: Chris@16: iterator_t last_target = ::boost::end(rng); Chris@16: for (iterator_t target = ::boost::begin(rng); target != last_target; ++target, ++x) Chris@16: *target = x; Chris@16: Chris@16: return rng; Chris@16: } Chris@16: Chris@16: template< class ForwardRange, class Value > Chris@16: inline const ForwardRange& iota( const ForwardRange& rng, Value x ) Chris@16: { Chris@16: BOOST_CONCEPT_ASSERT(( ForwardRangeConcept )); Chris@16: typedef BOOST_DEDUCED_TYPENAME range_iterator::type iterator_t; Chris@16: Chris@16: iterator_t last_target = ::boost::end(rng); Chris@16: for (iterator_t target = ::boost::begin(rng); target != last_target; ++target, ++x) Chris@16: *target = x; Chris@16: Chris@16: return rng; Chris@16: } Chris@16: Chris@16: } // namespace range Chris@16: using range::iota; Chris@16: } // namespace boost Chris@16: Chris@16: #endif // include guard