|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r60904 - trunk/boost/range/adaptor
From: neil_at_[hidden]
Date: 2010-03-28 15:44:33
Author: neilgroves
Date: 2010-03-28 15:44:33 EDT (Sun, 28 Mar 2010)
New Revision: 60904
URL: http://svn.boost.org/trac/boost/changeset/60904
Log:
Fix compilation of Boost.Range adaptors on GCC 64-bit
Text files modified:
trunk/boost/range/adaptor/copied.hpp | 34 +++++---------
trunk/boost/range/adaptor/indexed.hpp | 93 +++++++++++++++------------------------
trunk/boost/range/adaptor/sliced.hpp | 75 +++++++++++--------------------
3 files changed, 75 insertions(+), 127 deletions(-)
Modified: trunk/boost/range/adaptor/copied.hpp
==============================================================================
--- trunk/boost/range/adaptor/copied.hpp (original)
+++ trunk/boost/range/adaptor/copied.hpp 2010-03-28 15:44:33 EDT (Sun, 28 Mar 2010)
@@ -18,38 +18,28 @@
namespace boost
{
- namespace range_detail
- {
- template< class T >
- struct copy_holder
- : holder2<std::size_t>
- {
- copy_holder( std::size_t t, std::size_t u )
- : holder2<std::size_t>(t,u)
- { }
- };
-
- } // 'range_detail'
-
namespace adaptors
{
- template< class CopyableRandomAccessRng, class Int >
+ struct copied
+ {
+ copied(std::size_t t_, std::size_t u_)
+ : t(t_), u(u_) {}
+
+ std::size_t t;
+ std::size_t u;
+ };
+
+ template< class CopyableRandomAccessRng >
inline CopyableRandomAccessRng
- operator|( const CopyableRandomAccessRng& r, const range_detail::copy_holder<Int>& f )
+ operator|( const CopyableRandomAccessRng& r, const copied& f )
{
iterator_range<
BOOST_DEDUCED_TYPENAME range_iterator<const
CopyableRandomAccessRng>::type >
- temp( range_detail::sliced_impl( r, f ) );
+ temp( adaptors::slice( r, f.t, f.u ) );
return CopyableRandomAccessRng( temp.begin(), temp.end() );
}
- namespace
- {
- const range_detail::forwarder2<range_detail::copy_holder>
- copied = range_detail::forwarder2<range_detail::copy_holder>();
- }
-
template<class CopyableRandomAccessRange>
inline CopyableRandomAccessRange
copy(const CopyableRandomAccessRange& rng, std::size_t t, std::size_t u)
Modified: trunk/boost/range/adaptor/indexed.hpp
==============================================================================
--- trunk/boost/range/adaptor/indexed.hpp (original)
+++ trunk/boost/range/adaptor/indexed.hpp 2010-03-28 15:44:33 EDT (Sun, 28 Mar 2010)
@@ -27,7 +27,15 @@
namespace boost
{
-
+ namespace adaptors
+ {
+ struct indexed
+ {
+ explicit indexed(std::size_t x) : val(x) {}
+ std::size_t val;
+ };
+ }
+
namespace range_detail
{
template< class Iter >
@@ -35,16 +43,16 @@
: public boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
{
private:
- typedef boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
- base;
+ typedef boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
+ base;
typedef BOOST_DEDUCED_TYPENAME base::difference_type index_type;
index_type index_;
-
+
public:
explicit indexed_iterator( Iter i, index_type index )
- : base(i), index_(index)
+ : base(i), index_(index)
{
BOOST_ASSERT( index_ >= 0 && "Indexed Iterator out of bounds" );
}
@@ -53,12 +61,12 @@
{
return index_;
}
-
+
private:
friend class boost::iterator_core_access;
-
- void increment()
- {
+
+ void increment()
+ {
++index_;
++(this->base_reference());
}
@@ -80,7 +88,7 @@
};
template< class Rng >
- struct indexed_range :
+ struct indexed_range :
iterator_range< indexed_iterator<BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type> >
{
private:
@@ -90,49 +98,11 @@
base;
public:
template< class Index >
- indexed_range( Index i, Rng& r )
+ indexed_range( Index i, Rng& r )
: base( iter_type(boost::begin(r), i), iter_type(boost::end(r),i) )
{ }
};
-
- template< class T >
- struct index_holder : holder<T>
- {
- index_holder( T r ) : holder<T>(r)
- { }
- };
-
- struct index_forwarder
- {
- template< class T >
- index_holder<T> operator()( T r ) const
- {
- return r;
- }
-
- index_holder<int> operator()( int r = 0 ) const
- {
- return r;
- }
- };
-
- template< class SinglePassRange >
- inline indexed_range<SinglePassRange>
- operator|( SinglePassRange& r,
- const index_holder<typename range_difference<SinglePassRange>::type>& f )
- {
- return indexed_range<SinglePassRange>( f.val, r );
- }
-
- template< class SinglePassRange >
- inline indexed_range<const SinglePassRange>
- operator|( const SinglePassRange& r,
- const index_holder<typename range_difference<SinglePassRange>::type>& f )
- {
- return indexed_range<const SinglePassRange>( f.val, r );
- }
-
} // 'range_detail'
// Make this available to users of this library. It will sometimes be
@@ -141,21 +111,30 @@
using range_detail::indexed_range;
namespace adaptors
- {
- namespace
+ {
+ template< class SinglePassRange >
+ inline indexed_range<SinglePassRange>
+ operator|( SinglePassRange& r,
+ const indexed& f )
+ {
+ return indexed_range<SinglePassRange>( f.val, r );
+ }
+
+ template< class SinglePassRange >
+ inline indexed_range<const SinglePassRange>
+ operator|( const SinglePassRange& r,
+ const indexed& f )
{
- const range_detail::forwarder<range_detail::index_holder>
- indexed =
- range_detail::forwarder<range_detail::index_holder>();
+ return indexed_range<const SinglePassRange>( f.val, r );
}
-
+
template<class SinglePassRange, class Index>
inline indexed_range<SinglePassRange>
index(SinglePassRange& rng, Index index)
{
return indexed_range<SinglePassRange>(index, rng);
}
-
+
template<class SinglePassRange, class Index>
inline indexed_range<const SinglePassRange>
index(const SinglePassRange& rng, Index index)
@@ -163,7 +142,7 @@
return indexed_range<const SinglePassRange>(index, rng);
}
} // 'adaptors'
-
+
}
#ifdef BOOST_MSVC
Modified: trunk/boost/range/adaptor/sliced.hpp
==============================================================================
--- trunk/boost/range/adaptor/sliced.hpp (original)
+++ trunk/boost/range/adaptor/sliced.hpp 2010-03-28 15:44:33 EDT (Sun, 28 Mar 2010)
@@ -19,17 +19,25 @@
{
namespace adaptors
{
+ struct sliced
+ {
+ sliced(std::size_t t_, std::size_t u_)
+ : t(t_), u(u_) {}
+ std::size_t t;
+ std::size_t u;
+ };
+
template< class RandomAccessRange >
- inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
+ inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
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 &&
+ BOOST_ASSERT( static_cast<std::size_t>(boost::size(rng)) >= u &&
"second slice index out of bounds" );
- return make_iterator_range( rng, t, u - boost::size(rng) );
+ return boost::make_iterator_range( rng, t, u - boost::size(rng) );
}
-
+
template< class RandomAccessRange >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type >
slice( const RandomAccessRange& rng, std::size_t t, std::size_t u )
@@ -37,56 +45,27 @@
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 make_iterator_range( rng, t, u - boost::size(rng) );
- }
- } // 'adaptors'
-
- namespace range_detail
- {
- template< class T >
- struct slice_holder
- : holder2<std::size_t>
- {
- slice_holder( std::size_t t, std::size_t u )
- : holder2<std::size_t>(t,u)
- { }
- };
-
- template<class R, class H>
- inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<R>::type >
- sliced_impl( R& r, const H& f)
- {
- return adaptors::slice(r, f.val1, f.val2);
- }
-
- template< class RandomAccessRange, class Int >
- inline iterator_range<
- BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
- operator|( RandomAccessRange& r, const slice_holder<Int>& f )
- {
- return sliced_impl( r, f );
+
+ return boost::make_iterator_range( rng, t, u - boost::size(rng) );
}
- template< class RandomAccessRange, class Int >
- inline iterator_range<
- BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type >
- operator|( const RandomAccessRange& r, const slice_holder<Int>& f )
+ template< class RandomAccessRange >
+ inline iterator_range<
+ BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
+ operator|( RandomAccessRange& r, const sliced& f )
{
- return sliced_impl( r, f );
+ return adaptors::slice( r, f.t, f.u );
}
- } // 'range_detail'
-
- namespace adaptors
- {
- namespace
+ template< class RandomAccessRange >
+ inline iterator_range<
+ BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type >
+ operator|( const RandomAccessRange& r, const sliced& f )
{
- const range_detail::forwarder2<range_detail::slice_holder>
- sliced = range_detail::forwarder2<range_detail::slice_holder>();
+ return adaptors::slice( r, f.t, f.u );
}
- }
-
-}
+
+ } // namespace adaptors
+} // namespace boost
#endif
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