forked from boostorg/range
Boost.Range merge from trunk to release.
This is motivated by the need to correct the istream_range, to correct the adaptors.hpp header file, and correct the return types of various range algorithms. [SVN r61517]
This commit is contained in:
@ -40,56 +40,56 @@ namespace boost
|
||||
};
|
||||
}
|
||||
|
||||
namespace range_detail
|
||||
{
|
||||
template< class Iter >
|
||||
class indexed_iterator
|
||||
: public boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
|
||||
{
|
||||
private:
|
||||
typedef boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
|
||||
base;
|
||||
namespace range_detail
|
||||
{
|
||||
template< class Iter >
|
||||
class indexed_iterator
|
||||
: public boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
|
||||
{
|
||||
private:
|
||||
typedef boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
|
||||
base;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME base::difference_type index_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME base::difference_type index_type;
|
||||
|
||||
index_type m_index;
|
||||
index_type m_index;
|
||||
|
||||
public:
|
||||
explicit indexed_iterator( Iter i, index_type index )
|
||||
: base(i), m_index(index)
|
||||
{
|
||||
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
||||
}
|
||||
public:
|
||||
explicit indexed_iterator( Iter i, index_type index )
|
||||
: base(i), m_index(index)
|
||||
{
|
||||
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
||||
}
|
||||
|
||||
index_type index() const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
index_type index() const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
|
||||
void increment()
|
||||
{
|
||||
void increment()
|
||||
{
|
||||
++m_index;
|
||||
++(this->base_reference());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void decrement()
|
||||
void decrement()
|
||||
{
|
||||
BOOST_ASSERT( m_index > 0 && "Indexed Iterator out of bounds" );
|
||||
--m_index;
|
||||
--(this->base_reference());
|
||||
}
|
||||
|
||||
void advance( index_type n )
|
||||
void advance( index_type n )
|
||||
{
|
||||
m_index += n;
|
||||
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
||||
this->base_reference() += n;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template< class Rng >
|
||||
struct indexed_range :
|
||||
@ -107,45 +107,45 @@ namespace boost
|
||||
{ }
|
||||
};
|
||||
|
||||
} // 'range_detail'
|
||||
} // 'range_detail'
|
||||
|
||||
// Make this available to users of this library. It will sometimes be
|
||||
// required since it is the return type of operator '|' and
|
||||
// index().
|
||||
using range_detail::indexed_range;
|
||||
// Make this available to users of this library. It will sometimes be
|
||||
// required since it is the return type of operator '|' and
|
||||
// index().
|
||||
using range_detail::indexed_range;
|
||||
|
||||
namespace adaptors
|
||||
{
|
||||
namespace adaptors
|
||||
{
|
||||
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 )
|
||||
{
|
||||
return indexed_range<const SinglePassRange>( f.val, r );
|
||||
}
|
||||
|
||||
template<class SinglePassRange, class Index>
|
||||
inline indexed_range<SinglePassRange>
|
||||
index(SinglePassRange& rng, Index index_value)
|
||||
{
|
||||
return indexed_range<SinglePassRange>(index_value, rng);
|
||||
}
|
||||
|
||||
template<class SinglePassRange, class Index>
|
||||
inline indexed_range<const SinglePassRange>
|
||||
index(const SinglePassRange& rng, Index index_value)
|
||||
{
|
||||
return indexed_range<const SinglePassRange>(index_value, rng);
|
||||
inline indexed_range<SinglePassRange>
|
||||
operator|( SinglePassRange& r,
|
||||
const indexed& f )
|
||||
{
|
||||
return indexed_range<SinglePassRange>( f.val, r );
|
||||
}
|
||||
} // 'adaptors'
|
||||
|
||||
template< class SinglePassRange >
|
||||
inline indexed_range<const SinglePassRange>
|
||||
operator|( const SinglePassRange& r,
|
||||
const indexed& f )
|
||||
{
|
||||
return indexed_range<const SinglePassRange>( f.val, r );
|
||||
}
|
||||
|
||||
template<class SinglePassRange, class Index>
|
||||
inline indexed_range<SinglePassRange>
|
||||
index(SinglePassRange& rng, Index index_value)
|
||||
{
|
||||
return indexed_range<SinglePassRange>(index_value, rng);
|
||||
}
|
||||
|
||||
template<class SinglePassRange, class Index>
|
||||
inline indexed_range<const SinglePassRange>
|
||||
index(const SinglePassRange& rng, Index index_value)
|
||||
{
|
||||
return indexed_range<const SinglePassRange>(index_value, rng);
|
||||
}
|
||||
} // 'adaptors'
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user