forked from boostorg/range
Boost.Range minor documentation corrections and code comment fixes.
[SVN r61014]
This commit is contained in:
@ -104,7 +104,7 @@ namespace boost
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<R>::type raw_iterator;
|
||||
|
||||
P bi_pred;
|
||||
P m_bi_pred;
|
||||
|
||||
// Get the first element in the half-open range that
|
||||
// passes the filter predicate.
|
||||
@ -146,8 +146,8 @@ namespace boost
|
||||
adjacent_filter_range( const P& p, R& r, bool default_pass )
|
||||
: base_range( skip_iter( this, to_valid(boost::begin(r), boost::end(r), p, default_pass)),
|
||||
skip_iter( this, boost::end(r) ) ),
|
||||
bi_pred( p ),
|
||||
_default_pass(default_pass)
|
||||
m_bi_pred( p ),
|
||||
m_default_pass(default_pass)
|
||||
{
|
||||
}
|
||||
|
||||
@ -155,11 +155,11 @@ namespace boost
|
||||
{
|
||||
BOOST_ASSERT( current != this->end().base() );
|
||||
|
||||
current = to_valid(next(current), this->end().base(), bi_pred, _default_pass);
|
||||
current = to_valid(next(current), this->end().base(), m_bi_pred, m_default_pass);
|
||||
}
|
||||
|
||||
private:
|
||||
bool _default_pass;
|
||||
bool m_default_pass;
|
||||
};
|
||||
|
||||
template< class T >
|
||||
@ -214,7 +214,7 @@ namespace boost
|
||||
|
||||
// Bring adjacent_filter_range into the boost namespace so that users of
|
||||
// this library may specify the return type of the '|' operator and
|
||||
// make_adjacent_filtered_range()
|
||||
// adjacent_filter()
|
||||
using range_detail::adjacent_filter_range;
|
||||
|
||||
namespace adaptors
|
||||
@ -222,8 +222,8 @@ namespace boost
|
||||
namespace
|
||||
{
|
||||
const range_detail::forwarder<range_detail::adjacent_holder>
|
||||
adjacent_filtered =
|
||||
range_detail::forwarder<range_detail::adjacent_holder>();
|
||||
adjacent_filtered =
|
||||
range_detail::forwarder<range_detail::adjacent_holder>();
|
||||
|
||||
const range_detail::forwarder<range_detail::adjacent_excl_holder>
|
||||
adjacent_filtered_excl =
|
||||
|
@ -20,22 +20,21 @@ namespace boost
|
||||
namespace range_detail
|
||||
{
|
||||
template< class P, class R >
|
||||
struct filter_range :
|
||||
boost::iterator_range<
|
||||
boost::filter_iterator< P,
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||
>
|
||||
>
|
||||
struct filter_range :
|
||||
boost::iterator_range<
|
||||
boost::filter_iterator< P,
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||
>
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef boost::iterator_range<
|
||||
boost::filter_iterator< P,
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||
>
|
||||
>
|
||||
base;
|
||||
boost::filter_iterator< P,
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||
>
|
||||
> base;
|
||||
public:
|
||||
filter_range( P p, R& r )
|
||||
filter_range( P p, R& r )
|
||||
: base( make_filter_iterator( p, boost::begin(r), boost::end(r) ),
|
||||
make_filter_iterator( p, boost::end(r), boost::end(r) ) )
|
||||
{ }
|
||||
@ -47,48 +46,48 @@ namespace boost
|
||||
filter_holder( T r ) : holder<T>(r)
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
template< class InputRng, class Predicate >
|
||||
inline filter_range<Predicate, InputRng>
|
||||
operator|( InputRng& r,
|
||||
inline filter_range<Predicate, InputRng>
|
||||
operator|( InputRng& r,
|
||||
const filter_holder<Predicate>& f )
|
||||
{
|
||||
return filter_range<Predicate, InputRng>( f.val, r );
|
||||
return filter_range<Predicate, InputRng>( f.val, r );
|
||||
}
|
||||
|
||||
|
||||
template< class InputRng, class Predicate >
|
||||
inline filter_range<Predicate, const InputRng>
|
||||
operator|( const InputRng& r,
|
||||
inline filter_range<Predicate, const InputRng>
|
||||
operator|( const InputRng& r,
|
||||
const filter_holder<Predicate>& f )
|
||||
{
|
||||
return filter_range<Predicate, const InputRng>( f.val, r );
|
||||
return filter_range<Predicate, const InputRng>( f.val, r );
|
||||
}
|
||||
|
||||
|
||||
} // 'range_detail'
|
||||
|
||||
// Unusual use of 'using' is intended to bring filter_range into the boost namespace
|
||||
// while leaving the mechanics of the '|' operator in range_detail and maintain
|
||||
// argument dependent lookup.
|
||||
// filter_range logically needs to be in the boost namespace to allow user of
|
||||
// the library to define the return type for make_filtered_range()
|
||||
// the library to define the return type for filter()
|
||||
using range_detail::filter_range;
|
||||
|
||||
namespace adaptors
|
||||
{
|
||||
{
|
||||
namespace
|
||||
{
|
||||
const range_detail::forwarder<range_detail::filter_holder>
|
||||
filtered =
|
||||
const range_detail::forwarder<range_detail::filter_holder>
|
||||
filtered =
|
||||
range_detail::forwarder<range_detail::filter_holder>();
|
||||
}
|
||||
|
||||
|
||||
template<class InputRange, class Predicate>
|
||||
inline filter_range<Predicate, InputRange>
|
||||
filter(InputRange& rng, Predicate filter_pred)
|
||||
{
|
||||
return range_detail::filter_range<Predicate, InputRange>( filter_pred, rng );
|
||||
}
|
||||
|
||||
|
||||
template<class InputRange, class Predicate>
|
||||
inline filter_range<Predicate, const InputRange>
|
||||
filter(const InputRange& rng, Predicate filter_pred)
|
||||
|
@ -29,6 +29,10 @@ namespace boost
|
||||
{
|
||||
namespace adaptors
|
||||
{
|
||||
// This structure exists to carry the parameters from the '|' operator
|
||||
// to the index adapter. The expression rng | indexed(1) instantiates
|
||||
// this structure and passes it as the right-hand operand to the
|
||||
// '|' operator.
|
||||
struct indexed
|
||||
{
|
||||
explicit indexed(std::size_t x) : val(x) {}
|
||||
@ -48,18 +52,18 @@ namespace boost
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME base::difference_type index_type;
|
||||
|
||||
index_type index_;
|
||||
index_type m_index;
|
||||
|
||||
public:
|
||||
explicit indexed_iterator( Iter i, index_type index )
|
||||
: base(i), index_(index)
|
||||
: base(i), m_index(index)
|
||||
{
|
||||
BOOST_ASSERT( index_ >= 0 && "Indexed Iterator out of bounds" );
|
||||
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
||||
}
|
||||
|
||||
index_type index() const
|
||||
{
|
||||
return index_;
|
||||
return m_index;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -67,22 +71,22 @@ namespace boost
|
||||
|
||||
void increment()
|
||||
{
|
||||
++index_;
|
||||
++m_index;
|
||||
++(this->base_reference());
|
||||
}
|
||||
|
||||
|
||||
void decrement()
|
||||
{
|
||||
BOOST_ASSERT( index_ > 0 && "Indexed Iterator out of bounds" );
|
||||
--index_;
|
||||
BOOST_ASSERT( m_index > 0 && "Indexed Iterator out of bounds" );
|
||||
--m_index;
|
||||
--(this->base_reference());
|
||||
}
|
||||
|
||||
void advance( index_type n )
|
||||
{
|
||||
index_ += n;
|
||||
BOOST_ASSERT( index_ >= 0 && "Indexed Iterator out of bounds" );
|
||||
m_index += n;
|
||||
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
||||
this->base_reference() += n;
|
||||
}
|
||||
};
|
||||
@ -107,7 +111,7 @@ namespace boost
|
||||
|
||||
// Make this available to users of this library. It will sometimes be
|
||||
// required since it is the return type of operator '|' and
|
||||
// make_indexed_range().
|
||||
// index().
|
||||
using range_detail::indexed_range;
|
||||
|
||||
namespace adaptors
|
||||
@ -130,16 +134,16 @@ namespace boost
|
||||
|
||||
template<class SinglePassRange, class Index>
|
||||
inline indexed_range<SinglePassRange>
|
||||
index(SinglePassRange& rng, Index index)
|
||||
index(SinglePassRange& rng, Index index_value)
|
||||
{
|
||||
return indexed_range<SinglePassRange>(index, rng);
|
||||
return indexed_range<SinglePassRange>(index_value, rng);
|
||||
}
|
||||
|
||||
template<class SinglePassRange, class Index>
|
||||
inline indexed_range<const SinglePassRange>
|
||||
index(const SinglePassRange& rng, Index index)
|
||||
index(const SinglePassRange& rng, Index index_value)
|
||||
{
|
||||
return indexed_range<const SinglePassRange>(index, rng);
|
||||
return indexed_range<const SinglePassRange>(index_value, rng);
|
||||
}
|
||||
} // 'adaptors'
|
||||
|
||||
|
@ -21,22 +21,22 @@ namespace boost
|
||||
template< class R >
|
||||
struct indirect_range :
|
||||
public boost::iterator_range<
|
||||
boost::indirect_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||
>
|
||||
>
|
||||
boost::indirect_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||
>
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef boost::iterator_range<
|
||||
boost::indirect_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||
>
|
||||
>
|
||||
boost::indirect_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||
>
|
||||
>
|
||||
base;
|
||||
|
||||
public:
|
||||
indirect_range( R& r )
|
||||
: base( r )
|
||||
explicit indirect_range( R& r )
|
||||
: base( r )
|
||||
{ }
|
||||
};
|
||||
|
||||
|
@ -32,18 +32,18 @@ namespace boost
|
||||
typedef const Value& first_argument_type;
|
||||
|
||||
replace_value(const Value& from, const Value& to)
|
||||
: _from(from), _to(to)
|
||||
: m_from(from), m_to(to)
|
||||
{
|
||||
}
|
||||
|
||||
const Value& operator()(const Value& x) const
|
||||
{
|
||||
return (x == _from) ? _to : x;
|
||||
return (x == m_from) ? m_to : x;
|
||||
}
|
||||
|
||||
private:
|
||||
Value _from;
|
||||
Value _to;
|
||||
Value m_from;
|
||||
Value m_to;
|
||||
};
|
||||
|
||||
template< class R >
|
||||
@ -109,7 +109,7 @@ namespace boost
|
||||
replaced =
|
||||
range_detail::forwarder2<range_detail::replace_holder>();
|
||||
}
|
||||
|
||||
|
||||
template<class InputRange>
|
||||
inline replace_range<InputRange>
|
||||
replace(InputRange& rng,
|
||||
@ -118,7 +118,7 @@ namespace boost
|
||||
{
|
||||
return replace_range<InputRange>(rng, from, to);
|
||||
}
|
||||
|
||||
|
||||
template<class InputRange>
|
||||
inline replace_range<const InputRange>
|
||||
replace(const InputRange& rng,
|
||||
@ -127,7 +127,7 @@ namespace boost
|
||||
{
|
||||
return replace_range<const InputRange>(rng, from ,to);
|
||||
}
|
||||
|
||||
|
||||
} // 'adaptors'
|
||||
} // 'boost'
|
||||
|
||||
|
Reference in New Issue
Block a user