Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61923 - trunk/boost/range/adaptor
From: neil_at_[hidden]
Date: 2010-05-11 21:34:52


Author: neilgroves
Date: 2010-05-11 21:34:50 EDT (Tue, 11 May 2010)
New Revision: 61923
URL: http://svn.boost.org/trac/boost/changeset/61923

Log:
Boost.Range sliced adaptor is now compatible with VC10 even with using namespace boost::adaptors.
Text files modified:
   trunk/boost/range/adaptor/sliced.hpp | 28 +++++++++++++++++++---------
   1 files changed, 19 insertions(+), 9 deletions(-)

Modified: trunk/boost/range/adaptor/sliced.hpp
==============================================================================
--- trunk/boost/range/adaptor/sliced.hpp (original)
+++ trunk/boost/range/adaptor/sliced.hpp 2010-05-11 21:34:50 EDT (Tue, 11 May 2010)
@@ -28,14 +28,26 @@
         };
 
                 template< class RandomAccessRange >
- inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
+ class sliced_range : public boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
+ {
+ typedef boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type > base_t;
+ public:
+ template<typename Rng, typename T, typename U>
+ sliced_range(Rng& rng, T t, U u)
+ : base_t(boost::make_iterator_range(rng, t, u - boost::size(rng)))
+ {
+ }
+ };
+
+ template< class RandomAccessRange >
+ inline sliced_range<RandomAccessRange>
                 slice( RandomAccessRange& rng, std::size_t t, std::size_t u )
                 {
                         BOOST_ASSERT( t <= u && "error in slice indices" );
             BOOST_ASSERT( static_cast<std::size_t>(boost::size(rng)) >= u &&
                                                   "second slice index out of bounds" );
 
- return boost::make_iterator_range( rng, t, u - boost::size(rng) );
+ return sliced_range<RandomAccessRange>(rng, t, u);
                 }
 
                 template< class RandomAccessRange >
@@ -46,23 +58,21 @@
                     BOOST_ASSERT( static_cast<std::size_t>(boost::size(rng)) >= u &&
                                   "second slice index out of bounds" );
 
- return boost::make_iterator_range( rng, t, u - boost::size(rng) );
+ return sliced_range<const RandomAccessRange>(rng, t, u);
                 }
 
                 template< class RandomAccessRange >
- inline iterator_range<
- BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
+ inline sliced_range<RandomAccessRange>
                 operator|( RandomAccessRange& r, const sliced& f )
                 {
- return adaptors::slice( r, f.t, f.u );
+ return sliced_range<RandomAccessRange>( r, f.t, f.u );
                 }
 
                 template< class RandomAccessRange >
- inline iterator_range<
- BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type >
+ inline sliced_range<const RandomAccessRange>
                 operator|( const RandomAccessRange& r, const sliced& f )
                 {
- return adaptors::slice( r, f.t, f.u );
+ return sliced_range<const RandomAccessRange>( r, f.t, f.u );
                 }
 
     } // namespace adaptors


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk