mirror of
https://github.com/boostorg/range.git
synced 2025-07-16 06:02:34 +02:00
Fixed tab and no-newline-at-end-of-file issues from inspection report
[SVN r61435]
This commit is contained in:
@ -28,11 +28,11 @@
|
|||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template< class Iter, class Pred, bool default_pass >
|
template< class Iter, class Pred, bool default_pass >
|
||||||
class skip_iterator
|
class skip_iterator
|
||||||
: public boost::iterator_adaptor<
|
: public boost::iterator_adaptor<
|
||||||
skip_iterator<Iter,Pred,default_pass>,
|
skip_iterator<Iter,Pred,default_pass>,
|
||||||
Iter,
|
Iter,
|
||||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::value_type,
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::value_type,
|
||||||
@ -40,10 +40,10 @@ namespace boost
|
|||||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::reference,
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::reference,
|
||||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::difference_type
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::difference_type
|
||||||
>
|
>
|
||||||
, private Pred
|
, private Pred
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::iterator_adaptor<
|
typedef boost::iterator_adaptor<
|
||||||
skip_iterator<Iter,Pred,default_pass>,
|
skip_iterator<Iter,Pred,default_pass>,
|
||||||
Iter,
|
Iter,
|
||||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::value_type,
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::value_type,
|
||||||
@ -52,9 +52,9 @@ namespace boost
|
|||||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::difference_type
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<Iter>::difference_type
|
||||||
> base_t;
|
> base_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Pred pred_t;
|
typedef Pred pred_t;
|
||||||
typedef Iter iter_t;
|
typedef Iter iter_t;
|
||||||
|
|
||||||
skip_iterator() : m_last() {}
|
skip_iterator() : m_last() {}
|
||||||
|
|
||||||
@ -66,169 +66,169 @@ namespace boost
|
|||||||
move_to_next_valid();
|
move_to_next_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class OtherIter>
|
template<class OtherIter>
|
||||||
skip_iterator( const skip_iterator<OtherIter, pred_t, default_pass>& other )
|
skip_iterator( const skip_iterator<OtherIter, pred_t, default_pass>& other )
|
||||||
: base_t(other.base())
|
: base_t(other.base())
|
||||||
, pred_t(other)
|
, pred_t(other)
|
||||||
, m_last(other.m_last) {}
|
, m_last(other.m_last) {}
|
||||||
|
|
||||||
void move_to_next_valid()
|
void move_to_next_valid()
|
||||||
{
|
{
|
||||||
iter_t& it = this->base_reference();
|
iter_t& it = this->base_reference();
|
||||||
pred_t& bi_pred = *this;
|
pred_t& bi_pred = *this;
|
||||||
if (it != m_last)
|
if (it != m_last)
|
||||||
{
|
{
|
||||||
if (default_pass)
|
if (default_pass)
|
||||||
{
|
{
|
||||||
iter_t nxt = ::boost::next(it);
|
iter_t nxt = ::boost::next(it);
|
||||||
while (nxt != m_last && !bi_pred(*it, *nxt))
|
while (nxt != m_last && !bi_pred(*it, *nxt))
|
||||||
{
|
{
|
||||||
++it;
|
++it;
|
||||||
++nxt;
|
++nxt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iter_t nxt = ::boost::next(it);
|
iter_t nxt = ::boost::next(it);
|
||||||
for(; nxt != m_last; ++it, ++nxt)
|
for(; nxt != m_last; ++it, ++nxt)
|
||||||
{
|
{
|
||||||
if (bi_pred(*it, *nxt))
|
if (bi_pred(*it, *nxt))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nxt == m_last)
|
if (nxt == m_last)
|
||||||
{
|
{
|
||||||
it = m_last;
|
it = m_last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment()
|
void increment()
|
||||||
{
|
{
|
||||||
iter_t& it = this->base_reference();
|
iter_t& it = this->base_reference();
|
||||||
BOOST_ASSERT( it != m_last );
|
BOOST_ASSERT( it != m_last );
|
||||||
++it;
|
++it;
|
||||||
move_to_next_valid();
|
move_to_next_valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
iter_t m_last;
|
iter_t m_last;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class P, class R, bool default_pass >
|
template< class P, class R, bool default_pass >
|
||||||
struct adjacent_filter_range
|
struct adjacent_filter_range
|
||||||
: iterator_range< skip_iterator<
|
: iterator_range< skip_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type,
|
||||||
P,
|
P,
|
||||||
default_pass
|
default_pass
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef skip_iterator<
|
typedef skip_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type,
|
||||||
P,
|
P,
|
||||||
default_pass
|
default_pass
|
||||||
>
|
>
|
||||||
skip_iter;
|
skip_iter;
|
||||||
|
|
||||||
typedef iterator_range<skip_iter>
|
typedef iterator_range<skip_iter>
|
||||||
base_range;
|
base_range;
|
||||||
|
|
||||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<R>::type raw_iterator;
|
typedef BOOST_DEDUCED_TYPENAME range_iterator<R>::type raw_iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
adjacent_filter_range( const P& p, R& r )
|
adjacent_filter_range( const P& p, R& r )
|
||||||
: base_range( skip_iter( boost::begin(r), boost::end(r), p),
|
: base_range( skip_iter( boost::begin(r), boost::end(r), p),
|
||||||
skip_iter( boost::end(r), boost::end(r), p) )
|
skip_iter( boost::end(r), boost::end(r), p) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
struct adjacent_holder : holder<T>
|
struct adjacent_holder : holder<T>
|
||||||
{
|
{
|
||||||
adjacent_holder( T r ) : holder<T>(r)
|
adjacent_holder( T r ) : holder<T>(r)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
struct adjacent_excl_holder : holder<T>
|
struct adjacent_excl_holder : holder<T>
|
||||||
{
|
{
|
||||||
adjacent_excl_holder( T r ) : holder<T>(r)
|
adjacent_excl_holder( T r ) : holder<T>(r)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class ForwardRng, class BinPredicate >
|
template< class ForwardRng, class BinPredicate >
|
||||||
inline adjacent_filter_range<BinPredicate, ForwardRng, true>
|
inline adjacent_filter_range<BinPredicate, ForwardRng, true>
|
||||||
operator|( ForwardRng& r,
|
operator|( ForwardRng& r,
|
||||||
const adjacent_holder<BinPredicate>& f )
|
const adjacent_holder<BinPredicate>& f )
|
||||||
{
|
{
|
||||||
return adjacent_filter_range<BinPredicate, ForwardRng, true>( f.val, r );
|
return adjacent_filter_range<BinPredicate, ForwardRng, true>( f.val, r );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class ForwardRng, class BinPredicate >
|
template< class ForwardRng, class BinPredicate >
|
||||||
inline adjacent_filter_range<BinPredicate, const ForwardRng, true>
|
inline adjacent_filter_range<BinPredicate, const ForwardRng, true>
|
||||||
operator|( const ForwardRng& r,
|
operator|( const ForwardRng& r,
|
||||||
const adjacent_holder<BinPredicate>& f )
|
const adjacent_holder<BinPredicate>& f )
|
||||||
{
|
{
|
||||||
return adjacent_filter_range<BinPredicate,
|
return adjacent_filter_range<BinPredicate,
|
||||||
const ForwardRng, true>( f.val, r );
|
const ForwardRng, true>( f.val, r );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class ForwardRng, class BinPredicate >
|
template< class ForwardRng, class BinPredicate >
|
||||||
inline adjacent_filter_range<BinPredicate, ForwardRng, false>
|
inline adjacent_filter_range<BinPredicate, ForwardRng, false>
|
||||||
operator|( ForwardRng& r,
|
operator|( ForwardRng& r,
|
||||||
const adjacent_excl_holder<BinPredicate>& f )
|
const adjacent_excl_holder<BinPredicate>& f )
|
||||||
{
|
{
|
||||||
return adjacent_filter_range<BinPredicate, ForwardRng, false>( f.val, r );
|
return adjacent_filter_range<BinPredicate, ForwardRng, false>( f.val, r );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class ForwardRng, class BinPredicate >
|
template< class ForwardRng, class BinPredicate >
|
||||||
inline adjacent_filter_range<BinPredicate, ForwardRng, false>
|
inline adjacent_filter_range<BinPredicate, ForwardRng, false>
|
||||||
operator|( const ForwardRng& r,
|
operator|( const ForwardRng& r,
|
||||||
const adjacent_excl_holder<BinPredicate>& f )
|
const adjacent_excl_holder<BinPredicate>& f )
|
||||||
{
|
{
|
||||||
return adjacent_filter_range<BinPredicate,
|
return adjacent_filter_range<BinPredicate,
|
||||||
const ForwardRng, false>( f.val, r );
|
const ForwardRng, false>( f.val, r );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 'range_detail'
|
} // 'range_detail'
|
||||||
|
|
||||||
// Bring adjacent_filter_range into the boost namespace so that users of
|
// Bring adjacent_filter_range into the boost namespace so that users of
|
||||||
// this library may specify the return type of the '|' operator and
|
// this library may specify the return type of the '|' operator and
|
||||||
// adjacent_filter()
|
// adjacent_filter()
|
||||||
using range_detail::adjacent_filter_range;
|
using range_detail::adjacent_filter_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const range_detail::forwarder<range_detail::adjacent_holder>
|
const range_detail::forwarder<range_detail::adjacent_holder>
|
||||||
adjacent_filtered =
|
adjacent_filtered =
|
||||||
range_detail::forwarder<range_detail::adjacent_holder>();
|
range_detail::forwarder<range_detail::adjacent_holder>();
|
||||||
|
|
||||||
const range_detail::forwarder<range_detail::adjacent_excl_holder>
|
const range_detail::forwarder<range_detail::adjacent_excl_holder>
|
||||||
adjacent_filtered_excl =
|
adjacent_filtered_excl =
|
||||||
range_detail::forwarder<range_detail::adjacent_excl_holder>();
|
range_detail::forwarder<range_detail::adjacent_excl_holder>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ForwardRng, class BinPredicate>
|
template<class ForwardRng, class BinPredicate>
|
||||||
inline adjacent_filter_range<BinPredicate, ForwardRng, true>
|
inline adjacent_filter_range<BinPredicate, ForwardRng, true>
|
||||||
adjacent_filter(ForwardRng& rng, BinPredicate filter_pred)
|
adjacent_filter(ForwardRng& rng, BinPredicate filter_pred)
|
||||||
{
|
{
|
||||||
return adjacent_filter_range<BinPredicate, ForwardRng, true>(filter_pred, rng);
|
return adjacent_filter_range<BinPredicate, ForwardRng, true>(filter_pred, rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class ForwardRng, class BinPredicate>
|
template<class ForwardRng, class BinPredicate>
|
||||||
inline adjacent_filter_range<BinPredicate, const ForwardRng, true>
|
inline adjacent_filter_range<BinPredicate, const ForwardRng, true>
|
||||||
adjacent_filter(const ForwardRng& rng, BinPredicate filter_pred)
|
adjacent_filter(const ForwardRng& rng, BinPredicate filter_pred)
|
||||||
{
|
{
|
||||||
return adjacent_filter_range<BinPredicate, const ForwardRng, true>(filter_pred, rng);
|
return adjacent_filter_range<BinPredicate, const ForwardRng, true>(filter_pred, rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 'adaptors'
|
} // 'adaptors'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,57 +20,57 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template< class T >
|
template< class T >
|
||||||
struct holder
|
struct holder
|
||||||
{
|
{
|
||||||
T val;
|
T val;
|
||||||
holder( T t ) : val(t)
|
holder( T t ) : val(t)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
struct holder2
|
struct holder2
|
||||||
{
|
{
|
||||||
T val1, val2;
|
T val1, val2;
|
||||||
holder2( T t, T u ) : val1(t), val2(u)
|
holder2( T t, T u ) : val1(t), val2(u)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< template<class> class Holder >
|
template< template<class> class Holder >
|
||||||
struct forwarder
|
struct forwarder
|
||||||
{
|
{
|
||||||
template< class T >
|
template< class T >
|
||||||
Holder<T> operator()( T t ) const
|
Holder<T> operator()( T t ) const
|
||||||
{
|
{
|
||||||
return Holder<T>(t);
|
return Holder<T>(t);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< template<class> class Holder >
|
template< template<class> class Holder >
|
||||||
struct forwarder2
|
struct forwarder2
|
||||||
{
|
{
|
||||||
template< class T >
|
template< class T >
|
||||||
Holder<T> operator()( T t, T u ) const
|
Holder<T> operator()( T t, T u ) const
|
||||||
{
|
{
|
||||||
return Holder<T>(t,u);
|
return Holder<T>(t,u);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< template<class,class> class Holder >
|
template< template<class,class> class Holder >
|
||||||
struct forwarder2TU
|
struct forwarder2TU
|
||||||
{
|
{
|
||||||
template< class T, class U >
|
template< class T, class U >
|
||||||
Holder<T, U> operator()( T t, U u ) const
|
Holder<T, U> operator()( T t, U u ) const
|
||||||
{
|
{
|
||||||
return Holder<T, U>(t, u);
|
return Holder<T, U>(t, u);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BOOST_MSVC
|
#ifdef BOOST_MSVC
|
||||||
|
@ -18,40 +18,40 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
struct copied
|
struct copied
|
||||||
{
|
{
|
||||||
copied(std::size_t t_, std::size_t u_)
|
copied(std::size_t t_, std::size_t u_)
|
||||||
: t(t_), u(u_) {}
|
: t(t_), u(u_) {}
|
||||||
|
|
||||||
std::size_t t;
|
std::size_t t;
|
||||||
std::size_t u;
|
std::size_t u;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class CopyableRandomAccessRng >
|
template< class CopyableRandomAccessRng >
|
||||||
inline CopyableRandomAccessRng
|
inline CopyableRandomAccessRng
|
||||||
operator|( const CopyableRandomAccessRng& r, const copied& f )
|
operator|( const CopyableRandomAccessRng& r, const copied& f )
|
||||||
{
|
{
|
||||||
iterator_range<
|
iterator_range<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<const
|
BOOST_DEDUCED_TYPENAME range_iterator<const
|
||||||
CopyableRandomAccessRng>::type >
|
CopyableRandomAccessRng>::type >
|
||||||
temp( adaptors::slice( r, f.t, f.u ) );
|
temp( adaptors::slice( r, f.t, f.u ) );
|
||||||
return CopyableRandomAccessRng( temp.begin(), temp.end() );
|
return CopyableRandomAccessRng( temp.begin(), temp.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class CopyableRandomAccessRange>
|
template<class CopyableRandomAccessRange>
|
||||||
inline CopyableRandomAccessRange
|
inline CopyableRandomAccessRange
|
||||||
copy(const CopyableRandomAccessRange& rng, std::size_t t, std::size_t u)
|
copy(const CopyableRandomAccessRange& rng, std::size_t t, std::size_t u)
|
||||||
{
|
{
|
||||||
iterator_range<
|
iterator_range<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<const
|
BOOST_DEDUCED_TYPENAME range_iterator<const
|
||||||
CopyableRandomAccessRange>::type> temp(
|
CopyableRandomAccessRange>::type> temp(
|
||||||
adaptors::slice(rng, t, u));
|
adaptors::slice(rng, t, u));
|
||||||
|
|
||||||
return CopyableRandomAccessRange( temp.begin(), temp.end() );
|
return CopyableRandomAccessRange( temp.begin(), temp.end() );
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
} // 'adaptors'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,84 +17,84 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template< class P, class R >
|
template< class P, class R >
|
||||||
struct filter_range :
|
struct filter_range :
|
||||||
boost::iterator_range<
|
boost::iterator_range<
|
||||||
boost::filter_iterator< P,
|
boost::filter_iterator< P,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::iterator_range<
|
typedef boost::iterator_range<
|
||||||
boost::filter_iterator< P,
|
boost::filter_iterator< P,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
> base;
|
> base;
|
||||||
public:
|
public:
|
||||||
filter_range( P p, R& r )
|
filter_range( P p, R& r )
|
||||||
: base( make_filter_iterator( p, boost::begin(r), boost::end(r) ),
|
: base( make_filter_iterator( p, boost::begin(r), boost::end(r) ),
|
||||||
make_filter_iterator( p, boost::end(r), boost::end(r) ) )
|
make_filter_iterator( p, boost::end(r), boost::end(r) ) )
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
struct filter_holder : holder<T>
|
struct filter_holder : holder<T>
|
||||||
{
|
{
|
||||||
filter_holder( T r ) : holder<T>(r)
|
filter_holder( T r ) : holder<T>(r)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class InputRng, class Predicate >
|
template< class InputRng, class Predicate >
|
||||||
inline filter_range<Predicate, InputRng>
|
inline filter_range<Predicate, InputRng>
|
||||||
operator|( InputRng& r,
|
operator|( InputRng& r,
|
||||||
const filter_holder<Predicate>& f )
|
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,
|
|
||||||
const filter_holder<Predicate>& f )
|
|
||||||
{
|
|
||||||
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 filter()
|
|
||||||
using range_detail::filter_range;
|
|
||||||
|
|
||||||
namespace adaptors
|
|
||||||
{
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
return range_detail::filter_range<Predicate, const InputRange>( filter_pred, rng );
|
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
|
||||||
|
template< class InputRng, class Predicate >
|
||||||
|
inline filter_range<Predicate, const InputRng>
|
||||||
|
operator|( const InputRng& r,
|
||||||
|
const filter_holder<Predicate>& f )
|
||||||
|
{
|
||||||
|
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 filter()
|
||||||
|
using range_detail::filter_range;
|
||||||
|
|
||||||
|
namespace adaptors
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return range_detail::filter_range<Predicate, const InputRange>( filter_pred, rng );
|
||||||
|
}
|
||||||
|
} // 'adaptors'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,56 +40,56 @@ namespace boost
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template< class Iter >
|
template< class Iter >
|
||||||
class indexed_iterator
|
class indexed_iterator
|
||||||
: public boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
|
: public boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
|
typedef boost::iterator_adaptor< indexed_iterator<Iter>, Iter >
|
||||||
base;
|
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:
|
public:
|
||||||
explicit indexed_iterator( Iter i, index_type index )
|
explicit indexed_iterator( Iter i, index_type index )
|
||||||
: base(i), m_index(index)
|
: base(i), m_index(index)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
||||||
}
|
}
|
||||||
|
|
||||||
index_type index() const
|
index_type index() const
|
||||||
{
|
{
|
||||||
return m_index;
|
return m_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class boost::iterator_core_access;
|
friend class boost::iterator_core_access;
|
||||||
|
|
||||||
void increment()
|
void increment()
|
||||||
{
|
{
|
||||||
++m_index;
|
++m_index;
|
||||||
++(this->base_reference());
|
++(this->base_reference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void decrement()
|
void decrement()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( m_index > 0 && "Indexed Iterator out of bounds" );
|
BOOST_ASSERT( m_index > 0 && "Indexed Iterator out of bounds" );
|
||||||
--m_index;
|
--m_index;
|
||||||
--(this->base_reference());
|
--(this->base_reference());
|
||||||
}
|
}
|
||||||
|
|
||||||
void advance( index_type n )
|
void advance( index_type n )
|
||||||
{
|
{
|
||||||
m_index += n;
|
m_index += n;
|
||||||
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
BOOST_ASSERT( m_index >= 0 && "Indexed Iterator out of bounds" );
|
||||||
this->base_reference() += n;
|
this->base_reference() += n;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Rng >
|
template< class Rng >
|
||||||
struct indexed_range :
|
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
|
// Make this available to users of this library. It will sometimes be
|
||||||
// required since it is the return type of operator '|' and
|
// required since it is the return type of operator '|' and
|
||||||
// index().
|
// index().
|
||||||
using range_detail::indexed_range;
|
using range_detail::indexed_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
template< class SinglePassRange >
|
template< class SinglePassRange >
|
||||||
inline indexed_range<SinglePassRange>
|
inline indexed_range<SinglePassRange>
|
||||||
operator|( SinglePassRange& r,
|
operator|( SinglePassRange& r,
|
||||||
const indexed& f )
|
const indexed& f )
|
||||||
{
|
{
|
||||||
return indexed_range<SinglePassRange>( f.val, r );
|
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);
|
|
||||||
}
|
}
|
||||||
} // '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'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,72 +16,72 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template< class R >
|
template< class R >
|
||||||
struct indirect_range :
|
struct indirect_range :
|
||||||
public boost::iterator_range<
|
public boost::iterator_range<
|
||||||
boost::indirect_iterator<
|
boost::indirect_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::iterator_range<
|
typedef boost::iterator_range<
|
||||||
boost::indirect_iterator<
|
boost::indirect_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
base;
|
base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit indirect_range( R& r )
|
explicit indirect_range( R& r )
|
||||||
: base( r )
|
: base( r )
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct indirect_forwarder {};
|
struct indirect_forwarder {};
|
||||||
|
|
||||||
template< class InputRng >
|
template< class InputRng >
|
||||||
inline indirect_range<InputRng>
|
inline indirect_range<InputRng>
|
||||||
operator|( InputRng& r, indirect_forwarder )
|
operator|( InputRng& r, indirect_forwarder )
|
||||||
{
|
{
|
||||||
return indirect_range<InputRng>( r );
|
return indirect_range<InputRng>( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class InputRng >
|
template< class InputRng >
|
||||||
inline indirect_range<const InputRng>
|
inline indirect_range<const InputRng>
|
||||||
operator|( const InputRng& r, indirect_forwarder )
|
operator|( const InputRng& r, indirect_forwarder )
|
||||||
{
|
{
|
||||||
return indirect_range<const InputRng>( r );
|
return indirect_range<const InputRng>( r );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 'range_detail'
|
} // 'range_detail'
|
||||||
|
|
||||||
using range_detail::indirect_range;
|
using range_detail::indirect_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const range_detail::indirect_forwarder indirected =
|
const range_detail::indirect_forwarder indirected =
|
||||||
range_detail::indirect_forwarder();
|
range_detail::indirect_forwarder();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class InputRange>
|
template<class InputRange>
|
||||||
inline indirect_range<InputRange>
|
inline indirect_range<InputRange>
|
||||||
indirect(InputRange& rng)
|
indirect(InputRange& rng)
|
||||||
{
|
{
|
||||||
return indirect_range<InputRange>(rng);
|
return indirect_range<InputRange>(rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class InputRange>
|
template<class InputRange>
|
||||||
inline indirect_range<const InputRange>
|
inline indirect_range<const InputRange>
|
||||||
indirect(const InputRange& rng)
|
indirect(const InputRange& rng)
|
||||||
{
|
{
|
||||||
return indirect_range<const InputRange>(rng);
|
return indirect_range<const InputRange>(rng);
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
} // 'adaptors'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,161 +17,161 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
struct map_keys_forwarder {};
|
struct map_keys_forwarder {};
|
||||||
struct map_values_forwarder {};
|
struct map_values_forwarder {};
|
||||||
|
|
||||||
template< class Map >
|
template< class Map >
|
||||||
struct select_first
|
struct select_first
|
||||||
{
|
{
|
||||||
typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t;
|
typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t;
|
||||||
typedef const BOOST_DEDUCED_TYPENAME pair_t::first_type&
|
typedef const BOOST_DEDUCED_TYPENAME pair_t::first_type&
|
||||||
result_type;
|
result_type;
|
||||||
|
|
||||||
result_type operator()( const pair_t& r ) const
|
result_type operator()( const pair_t& r ) const
|
||||||
{
|
{
|
||||||
return r.first;
|
return r.first;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Map >
|
template< class Map >
|
||||||
struct select_second_mutable
|
struct select_second_mutable
|
||||||
{
|
{
|
||||||
typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t;
|
typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t;
|
||||||
typedef BOOST_DEDUCED_TYPENAME pair_t::second_type& result_type;
|
typedef BOOST_DEDUCED_TYPENAME pair_t::second_type& result_type;
|
||||||
|
|
||||||
result_type operator()( pair_t& r ) const
|
result_type operator()( pair_t& r ) const
|
||||||
{
|
{
|
||||||
return r.second;
|
return r.second;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Map >
|
template< class Map >
|
||||||
struct select_second_const
|
struct select_second_const
|
||||||
{
|
{
|
||||||
typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t;
|
typedef BOOST_DEDUCED_TYPENAME Map::value_type pair_t;
|
||||||
typedef const BOOST_DEDUCED_TYPENAME pair_t::second_type&
|
typedef const BOOST_DEDUCED_TYPENAME pair_t::second_type&
|
||||||
result_type;
|
result_type;
|
||||||
|
|
||||||
result_type operator()( const pair_t& r ) const
|
result_type operator()( const pair_t& r ) const
|
||||||
{
|
{
|
||||||
return r.second;
|
return r.second;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class StdPairRng>
|
template<class StdPairRng>
|
||||||
class select_first_range
|
class select_first_range
|
||||||
: public transform_range<
|
: public transform_range<
|
||||||
select_first<StdPairRng>,
|
select_first<StdPairRng>,
|
||||||
const StdPairRng>
|
const StdPairRng>
|
||||||
{
|
{
|
||||||
typedef transform_range<select_first<StdPairRng>, const StdPairRng> base;
|
typedef transform_range<select_first<StdPairRng>, const StdPairRng> base;
|
||||||
public:
|
public:
|
||||||
typedef select_first<StdPairRng> transform_fn_type;
|
typedef select_first<StdPairRng> transform_fn_type;
|
||||||
typedef const StdPairRng source_range_type;
|
typedef const StdPairRng source_range_type;
|
||||||
|
|
||||||
select_first_range(transform_fn_type fn, source_range_type& rng)
|
select_first_range(transform_fn_type fn, source_range_type& rng)
|
||||||
: base(fn, rng)
|
: base(fn, rng)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
select_first_range(const base& other) : base(other) {}
|
select_first_range(const base& other) : base(other) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class StdPairRng>
|
template<class StdPairRng>
|
||||||
class select_second_mutable_range
|
class select_second_mutable_range
|
||||||
: public transform_range<
|
: public transform_range<
|
||||||
select_second_mutable<StdPairRng>,
|
select_second_mutable<StdPairRng>,
|
||||||
StdPairRng>
|
StdPairRng>
|
||||||
{
|
{
|
||||||
typedef transform_range<select_second_mutable<StdPairRng>, StdPairRng> base;
|
typedef transform_range<select_second_mutable<StdPairRng>, StdPairRng> base;
|
||||||
public:
|
public:
|
||||||
typedef select_second_mutable<StdPairRng> transform_fn_type;
|
typedef select_second_mutable<StdPairRng> transform_fn_type;
|
||||||
typedef StdPairRng source_range_type;
|
typedef StdPairRng source_range_type;
|
||||||
|
|
||||||
select_second_mutable_range(transform_fn_type fn, source_range_type& rng)
|
select_second_mutable_range(transform_fn_type fn, source_range_type& rng)
|
||||||
: base(fn, rng)
|
: base(fn, rng)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
select_second_mutable_range(const base& other) : base(other) {}
|
select_second_mutable_range(const base& other) : base(other) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class StdPairRng>
|
template<class StdPairRng>
|
||||||
class select_second_const_range
|
class select_second_const_range
|
||||||
: public transform_range<
|
: public transform_range<
|
||||||
select_second_const<StdPairRng>,
|
select_second_const<StdPairRng>,
|
||||||
const StdPairRng>
|
const StdPairRng>
|
||||||
{
|
{
|
||||||
typedef transform_range<select_second_const<StdPairRng>, const StdPairRng> base;
|
typedef transform_range<select_second_const<StdPairRng>, const StdPairRng> base;
|
||||||
public:
|
public:
|
||||||
typedef select_second_const<StdPairRng> transform_fn_type;
|
typedef select_second_const<StdPairRng> transform_fn_type;
|
||||||
typedef const StdPairRng source_range_type;
|
typedef const StdPairRng source_range_type;
|
||||||
|
|
||||||
select_second_const_range(transform_fn_type fn, source_range_type& rng)
|
select_second_const_range(transform_fn_type fn, source_range_type& rng)
|
||||||
: base(fn, rng)
|
: base(fn, rng)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
select_second_const_range(const base& other) : base(other) {}
|
select_second_const_range(const base& other) : base(other) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class StdPairRng >
|
template< class StdPairRng >
|
||||||
inline select_first_range<StdPairRng>
|
inline select_first_range<StdPairRng>
|
||||||
operator|( const StdPairRng& r, map_keys_forwarder )
|
operator|( const StdPairRng& r, map_keys_forwarder )
|
||||||
{
|
{
|
||||||
return operator|( r,
|
return operator|( r,
|
||||||
boost::adaptors::transformed( select_first<StdPairRng>() ) );
|
boost::adaptors::transformed( select_first<StdPairRng>() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class StdPairRng >
|
template< class StdPairRng >
|
||||||
inline select_second_mutable_range<StdPairRng>
|
inline select_second_mutable_range<StdPairRng>
|
||||||
operator|( StdPairRng& r, map_values_forwarder )
|
operator|( StdPairRng& r, map_values_forwarder )
|
||||||
{
|
{
|
||||||
return operator|( r,
|
return operator|( r,
|
||||||
boost::adaptors::transformed( select_second_mutable<StdPairRng>() ) );
|
boost::adaptors::transformed( select_second_mutable<StdPairRng>() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class StdPairRng >
|
template< class StdPairRng >
|
||||||
inline select_second_const_range<StdPairRng>
|
inline select_second_const_range<StdPairRng>
|
||||||
operator|( const StdPairRng& r, map_values_forwarder )
|
operator|( const StdPairRng& r, map_values_forwarder )
|
||||||
{
|
{
|
||||||
return operator|( r,
|
return operator|( r,
|
||||||
boost::adaptors::transformed( select_second_const<StdPairRng>() ) );
|
boost::adaptors::transformed( select_second_const<StdPairRng>() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 'range_detail'
|
} // 'range_detail'
|
||||||
|
|
||||||
using range_detail::select_first_range;
|
using range_detail::select_first_range;
|
||||||
using range_detail::select_second_mutable_range;
|
using range_detail::select_second_mutable_range;
|
||||||
using range_detail::select_second_const_range;
|
using range_detail::select_second_const_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const range_detail::map_keys_forwarder map_keys =
|
const range_detail::map_keys_forwarder map_keys =
|
||||||
range_detail::map_keys_forwarder();
|
range_detail::map_keys_forwarder();
|
||||||
|
|
||||||
const range_detail::map_values_forwarder map_values =
|
const range_detail::map_values_forwarder map_values =
|
||||||
range_detail::map_values_forwarder();
|
range_detail::map_values_forwarder();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class StdPairRange>
|
template<class StdPairRange>
|
||||||
inline select_first_range<StdPairRange>
|
inline select_first_range<StdPairRange>
|
||||||
keys(const StdPairRange& rng)
|
keys(const StdPairRange& rng)
|
||||||
{
|
{
|
||||||
return select_first_range<StdPairRange>(
|
return select_first_range<StdPairRange>(
|
||||||
range_detail::select_first<StdPairRange>(), rng );
|
range_detail::select_first<StdPairRange>(), rng );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class StdPairRange>
|
template<class StdPairRange>
|
||||||
inline select_second_const_range<StdPairRange>
|
inline select_second_const_range<StdPairRange>
|
||||||
values(const StdPairRange& rng)
|
values(const StdPairRange& rng)
|
||||||
{
|
{
|
||||||
return select_second_const_range<StdPairRange>(
|
return select_second_const_range<StdPairRange>(
|
||||||
range_detail::select_second_const<StdPairRange>(), rng );
|
range_detail::select_second_const<StdPairRange>(), rng );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class StdPairRange>
|
template<class StdPairRange>
|
||||||
@ -181,8 +181,8 @@ namespace boost
|
|||||||
return select_second_mutable_range<StdPairRange>(
|
return select_second_mutable_range<StdPairRange>(
|
||||||
range_detail::select_second_mutable<StdPairRange>(), rng );
|
range_detail::select_second_mutable<StdPairRange>(), rng );
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
} // 'adaptors'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,99 +22,99 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template< class Value >
|
template< class Value >
|
||||||
class replace_value
|
class replace_value
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef const Value& result_type;
|
typedef const Value& result_type;
|
||||||
typedef const Value& first_argument_type;
|
typedef const Value& first_argument_type;
|
||||||
|
|
||||||
replace_value(const Value& from, const Value& to)
|
replace_value(const Value& from, const Value& to)
|
||||||
: m_from(from), m_to(to)
|
: m_from(from), m_to(to)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const Value& operator()(const Value& x) const
|
const Value& operator()(const Value& x) const
|
||||||
{
|
{
|
||||||
return (x == m_from) ? m_to : x;
|
return (x == m_from) ? m_to : x;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Value m_from;
|
Value m_from;
|
||||||
Value m_to;
|
Value m_to;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class R >
|
template< class R >
|
||||||
class replace_range :
|
class replace_range :
|
||||||
public boost::iterator_range<
|
public boost::iterator_range<
|
||||||
boost::transform_iterator<
|
boost::transform_iterator<
|
||||||
replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type >,
|
replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type >,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type > >
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type > >
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type > Fn;
|
typedef replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type > Fn;
|
||||||
|
|
||||||
typedef boost::iterator_range<
|
typedef boost::iterator_range<
|
||||||
boost::transform_iterator<
|
boost::transform_iterator<
|
||||||
replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type >,
|
replace_value< BOOST_DEDUCED_TYPENAME range_value<R>::type >,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type > > base_t;
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type > > base_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef BOOST_DEDUCED_TYPENAME range_value<R>::type value_type;
|
typedef BOOST_DEDUCED_TYPENAME range_value<R>::type value_type;
|
||||||
|
|
||||||
replace_range( R& r, value_type from, value_type to )
|
replace_range( R& r, value_type from, value_type to )
|
||||||
: base_t( make_transform_iterator( boost::begin(r), Fn(from, to) ),
|
: base_t( make_transform_iterator( boost::begin(r), Fn(from, to) ),
|
||||||
make_transform_iterator( boost::end(r), Fn(from, to) ) )
|
make_transform_iterator( boost::end(r), Fn(from, to) ) )
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
class replace_holder : public holder2<T>
|
class replace_holder : public holder2<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
replace_holder( const T& from, const T& to )
|
replace_holder( const T& from, const T& to )
|
||||||
: holder2<T>(from, to)
|
: holder2<T>(from, to)
|
||||||
{ }
|
{ }
|
||||||
private:
|
private:
|
||||||
// not assignable
|
// not assignable
|
||||||
void operator=(const replace_holder&);
|
void operator=(const replace_holder&);
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class InputRng >
|
template< class InputRng >
|
||||||
inline replace_range<InputRng>
|
inline replace_range<InputRng>
|
||||||
operator|( InputRng& r,
|
operator|( InputRng& r,
|
||||||
const replace_holder<BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
|
const replace_holder<BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
|
||||||
{
|
{
|
||||||
return replace_range<InputRng>(r, f.val1, f.val2);
|
return replace_range<InputRng>(r, f.val1, f.val2);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class InputRng >
|
template< class InputRng >
|
||||||
inline replace_range<const InputRng>
|
inline replace_range<const InputRng>
|
||||||
operator|( const InputRng& r,
|
operator|( const InputRng& r,
|
||||||
const replace_holder<BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
|
const replace_holder<BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
|
||||||
{
|
{
|
||||||
return replace_range<const InputRng>(r, f.val1, f.val2);
|
return replace_range<const InputRng>(r, f.val1, f.val2);
|
||||||
}
|
}
|
||||||
} // 'range_detail'
|
} // 'range_detail'
|
||||||
|
|
||||||
using range_detail::replace_range;
|
using range_detail::replace_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const range_detail::forwarder2<range_detail::replace_holder>
|
const range_detail::forwarder2<range_detail::replace_holder>
|
||||||
replaced =
|
replaced =
|
||||||
range_detail::forwarder2<range_detail::replace_holder>();
|
range_detail::forwarder2<range_detail::replace_holder>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class InputRange>
|
template<class InputRange>
|
||||||
inline replace_range<InputRange>
|
inline replace_range<InputRange>
|
||||||
replace(InputRange& rng,
|
replace(InputRange& rng,
|
||||||
BOOST_DEDUCED_TYPENAME range_value<InputRange>::type from,
|
BOOST_DEDUCED_TYPENAME range_value<InputRange>::type from,
|
||||||
BOOST_DEDUCED_TYPENAME range_value<InputRange>::type to)
|
BOOST_DEDUCED_TYPENAME range_value<InputRange>::type to)
|
||||||
{
|
{
|
||||||
return replace_range<InputRange>(rng, from, to);
|
return replace_range<InputRange>(rng, from, to);
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ namespace boost
|
|||||||
return replace_range<const InputRange>(rng, from ,to);
|
return replace_range<const InputRange>(rng, from ,to);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 'adaptors'
|
} // 'adaptors'
|
||||||
} // 'boost'
|
} // 'boost'
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
@ -22,115 +22,115 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template< class Pred, class Value >
|
template< class Pred, class Value >
|
||||||
class replace_value_if
|
class replace_value_if
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef const Value& result_type;
|
typedef const Value& result_type;
|
||||||
typedef const Value& first_argument_type;
|
typedef const Value& first_argument_type;
|
||||||
|
|
||||||
replace_value_if(const Pred& pred, const Value& to)
|
replace_value_if(const Pred& pred, const Value& to)
|
||||||
: m_pred(pred), m_to(to)
|
: m_pred(pred), m_to(to)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const Value& operator()(const Value& x) const
|
const Value& operator()(const Value& x) const
|
||||||
{
|
{
|
||||||
return m_pred(x) ? m_to : x;
|
return m_pred(x) ? m_to : x;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Pred m_pred;
|
Pred m_pred;
|
||||||
Value m_to;
|
Value m_to;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Pred, class R >
|
template< class Pred, class R >
|
||||||
class replace_if_range :
|
class replace_if_range :
|
||||||
public boost::iterator_range<
|
public boost::iterator_range<
|
||||||
boost::transform_iterator<
|
boost::transform_iterator<
|
||||||
replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type >,
|
replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type >,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type > >
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type > >
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type > Fn;
|
typedef replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type > Fn;
|
||||||
|
|
||||||
typedef boost::iterator_range<
|
typedef boost::iterator_range<
|
||||||
boost::transform_iterator<
|
boost::transform_iterator<
|
||||||
replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type >,
|
replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type >,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type > > base_t;
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type > > base_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef BOOST_DEDUCED_TYPENAME range_value<R>::type value_type;
|
typedef BOOST_DEDUCED_TYPENAME range_value<R>::type value_type;
|
||||||
|
|
||||||
replace_if_range( R& r, const Pred& pred, value_type to )
|
replace_if_range( R& r, const Pred& pred, value_type to )
|
||||||
: base_t( make_transform_iterator( boost::begin(r), Fn(pred, to) ),
|
: base_t( make_transform_iterator( boost::begin(r), Fn(pred, to) ),
|
||||||
make_transform_iterator( boost::end(r), Fn(pred, to) ) )
|
make_transform_iterator( boost::end(r), Fn(pred, to) ) )
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Pred, class T >
|
template< class Pred, class T >
|
||||||
class replace_if_holder
|
class replace_if_holder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
replace_if_holder( const Pred& pred, const T& to )
|
replace_if_holder( const Pred& pred, const T& to )
|
||||||
: m_pred(pred), m_to(to)
|
: m_pred(pred), m_to(to)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
const Pred& pred() const { return m_pred; }
|
const Pred& pred() const { return m_pred; }
|
||||||
const T& to() const { return m_to; }
|
const T& to() const { return m_to; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Pred m_pred;
|
Pred m_pred;
|
||||||
T m_to;
|
T m_to;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Pred, class InputRng >
|
template< class Pred, class InputRng >
|
||||||
inline replace_if_range<Pred, InputRng>
|
inline replace_if_range<Pred, InputRng>
|
||||||
operator|( InputRng& r,
|
operator|( InputRng& r,
|
||||||
const replace_if_holder<Pred, BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
|
const replace_if_holder<Pred, BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
|
||||||
{
|
{
|
||||||
return replace_if_range<Pred, InputRng>(r, f.pred(), f.to());
|
return replace_if_range<Pred, InputRng>(r, f.pred(), f.to());
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class Pred, class InputRng >
|
template< class Pred, class InputRng >
|
||||||
inline replace_if_range<Pred, const InputRng>
|
inline replace_if_range<Pred, const InputRng>
|
||||||
operator|( const InputRng& r,
|
operator|( const InputRng& r,
|
||||||
const replace_if_holder<Pred, BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
|
const replace_if_holder<Pred, BOOST_DEDUCED_TYPENAME range_value<InputRng>::type>& f )
|
||||||
{
|
{
|
||||||
return replace_if_range<Pred, const InputRng>(r, f.pred(), f.to());
|
return replace_if_range<Pred, const InputRng>(r, f.pred(), f.to());
|
||||||
}
|
}
|
||||||
} // 'range_detail'
|
} // 'range_detail'
|
||||||
|
|
||||||
using range_detail::replace_if_range;
|
using range_detail::replace_if_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const range_detail::forwarder2TU<range_detail::replace_if_holder>
|
const range_detail::forwarder2TU<range_detail::replace_if_holder>
|
||||||
replaced_if =
|
replaced_if =
|
||||||
range_detail::forwarder2TU<range_detail::replace_if_holder>();
|
range_detail::forwarder2TU<range_detail::replace_if_holder>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Pred, class InputRange>
|
template<class Pred, class InputRange>
|
||||||
inline replace_if_range<Pred, InputRange>
|
inline replace_if_range<Pred, InputRange>
|
||||||
replace_if(InputRange& rng, Pred pred,
|
replace_if(InputRange& rng, Pred pred,
|
||||||
BOOST_DEDUCED_TYPENAME range_value<InputRange>::type to)
|
BOOST_DEDUCED_TYPENAME range_value<InputRange>::type to)
|
||||||
{
|
{
|
||||||
return range_detail::replace_if_range<Pred, InputRange>(rng, pred, to);
|
return range_detail::replace_if_range<Pred, InputRange>(rng, pred, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Pred, class InputRange>
|
template<class Pred, class InputRange>
|
||||||
inline replace_if_range<Pred, const InputRange>
|
inline replace_if_range<Pred, const InputRange>
|
||||||
replace_if(const InputRange& rng, Pred pred,
|
replace_if(const InputRange& rng, Pred pred,
|
||||||
BOOST_DEDUCED_TYPENAME range_value<const InputRange>::type to)
|
BOOST_DEDUCED_TYPENAME range_value<const InputRange>::type to)
|
||||||
{
|
{
|
||||||
return range_detail::replace_if_range<Pred, const InputRange>(rng, pred, to);
|
return range_detail::replace_if_range<Pred, const InputRange>(rng, pred, to);
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
} // 'adaptors'
|
||||||
|
|
||||||
} // 'boost'
|
} // 'boost'
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
@ -16,75 +16,75 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template< class R >
|
template< class R >
|
||||||
struct reverse_range :
|
struct reverse_range :
|
||||||
public boost::iterator_range<
|
public boost::iterator_range<
|
||||||
boost::reverse_iterator<
|
boost::reverse_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::iterator_range<
|
typedef boost::iterator_range<
|
||||||
boost::reverse_iterator<
|
boost::reverse_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
base;
|
base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef boost::reverse_iterator<BOOST_DEDUCED_TYPENAME range_iterator<R>::type> iterator;
|
typedef boost::reverse_iterator<BOOST_DEDUCED_TYPENAME range_iterator<R>::type> iterator;
|
||||||
|
|
||||||
reverse_range( R& r )
|
reverse_range( R& r )
|
||||||
: base( iterator(boost::end(r)), iterator(boost::begin(r)) )
|
: base( iterator(boost::end(r)), iterator(boost::begin(r)) )
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct reverse_forwarder {};
|
struct reverse_forwarder {};
|
||||||
|
|
||||||
template< class BidirectionalRng >
|
template< class BidirectionalRng >
|
||||||
inline reverse_range<BidirectionalRng>
|
inline reverse_range<BidirectionalRng>
|
||||||
operator|( BidirectionalRng& r, reverse_forwarder )
|
operator|( BidirectionalRng& r, reverse_forwarder )
|
||||||
{
|
{
|
||||||
return reverse_range<BidirectionalRng>( r );
|
return reverse_range<BidirectionalRng>( r );
|
||||||
}
|
|
||||||
|
|
||||||
template< class BidirectionalRng >
|
|
||||||
inline reverse_range<const BidirectionalRng>
|
|
||||||
operator|( const BidirectionalRng& r, reverse_forwarder )
|
|
||||||
{
|
|
||||||
return reverse_range<const BidirectionalRng>( r );
|
|
||||||
}
|
|
||||||
|
|
||||||
} // 'range_detail'
|
|
||||||
|
|
||||||
using range_detail::reverse_range;
|
|
||||||
|
|
||||||
namespace adaptors
|
|
||||||
{
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
const range_detail::reverse_forwarder reversed =
|
|
||||||
range_detail::reverse_forwarder();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class BidirectionalRange>
|
|
||||||
inline reverse_range<BidirectionalRange>
|
|
||||||
reverse(BidirectionalRange& rng)
|
|
||||||
{
|
|
||||||
return reverse_range<BidirectionalRange>(rng);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class BidirectionalRange>
|
|
||||||
inline reverse_range<const BidirectionalRange>
|
|
||||||
reverse(const BidirectionalRange& rng)
|
|
||||||
{
|
|
||||||
return reverse_range<const BidirectionalRange>(rng);
|
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
|
||||||
|
template< class BidirectionalRng >
|
||||||
|
inline reverse_range<const BidirectionalRng>
|
||||||
|
operator|( const BidirectionalRng& r, reverse_forwarder )
|
||||||
|
{
|
||||||
|
return reverse_range<const BidirectionalRng>( r );
|
||||||
|
}
|
||||||
|
|
||||||
|
} // 'range_detail'
|
||||||
|
|
||||||
|
using range_detail::reverse_range;
|
||||||
|
|
||||||
|
namespace adaptors
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const range_detail::reverse_forwarder reversed =
|
||||||
|
range_detail::reverse_forwarder();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class BidirectionalRange>
|
||||||
|
inline reverse_range<BidirectionalRange>
|
||||||
|
reverse(BidirectionalRange& rng)
|
||||||
|
{
|
||||||
|
return reverse_range<BidirectionalRange>(rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class BidirectionalRange>
|
||||||
|
inline reverse_range<const BidirectionalRange>
|
||||||
|
reverse(const BidirectionalRange& rng)
|
||||||
|
{
|
||||||
|
return reverse_range<const BidirectionalRange>(rng);
|
||||||
|
}
|
||||||
|
} // 'adaptors'
|
||||||
|
|
||||||
} // 'boost'
|
} // 'boost'
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,24 +27,24 @@ namespace boost
|
|||||||
std::size_t u;
|
std::size_t u;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class RandomAccessRange >
|
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 )
|
slice( RandomAccessRange& rng, std::size_t t, std::size_t u )
|
||||||
{
|
{
|
||||||
BOOST_ASSERT( t <= u && "error in slice indices" );
|
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" );
|
"second slice index out of bounds" );
|
||||||
|
|
||||||
return boost::make_iterator_range( rng, t, u - boost::size(rng) );
|
return boost::make_iterator_range( rng, t, u - boost::size(rng) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class RandomAccessRange >
|
template< class RandomAccessRange >
|
||||||
inline iterator_range<
|
inline iterator_range<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
|
BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
|
||||||
operator|( RandomAccessRange& r, const sliced& f )
|
operator|( RandomAccessRange& r, const sliced& f )
|
||||||
{
|
{
|
||||||
return adaptors::slice( r, f.t, f.u );
|
return adaptors::slice( r, f.t, f.u );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace adaptors
|
} // namespace adaptors
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
@ -18,132 +18,132 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template<typename BaseIterator>
|
template<typename BaseIterator>
|
||||||
class strided_iterator
|
class strided_iterator
|
||||||
: public iterator_adaptor<
|
: public iterator_adaptor<
|
||||||
strided_iterator<BaseIterator>,
|
strided_iterator<BaseIterator>,
|
||||||
BaseIterator>
|
BaseIterator>
|
||||||
{
|
{
|
||||||
friend class iterator_core_access;
|
friend class iterator_core_access;
|
||||||
|
|
||||||
typedef iterator_adaptor<strided_iterator<BaseIterator>, BaseIterator> super_t;
|
typedef iterator_adaptor<strided_iterator<BaseIterator>, BaseIterator> super_t;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
|
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
|
||||||
|
|
||||||
strided_iterator() : m_stride() { }
|
strided_iterator() : m_stride() { }
|
||||||
|
|
||||||
strided_iterator(const strided_iterator& other)
|
strided_iterator(const strided_iterator& other)
|
||||||
: super_t(other), m_stride(other.m_stride) { }
|
: super_t(other), m_stride(other.m_stride) { }
|
||||||
|
|
||||||
explicit strided_iterator(BaseIterator base_it, difference_type stride)
|
explicit strided_iterator(BaseIterator base_it, difference_type stride)
|
||||||
: super_t(base_it), m_stride(stride) { }
|
: super_t(base_it), m_stride(stride) { }
|
||||||
|
|
||||||
strided_iterator&
|
strided_iterator&
|
||||||
operator=(const strided_iterator& other)
|
operator=(const strided_iterator& other)
|
||||||
{
|
{
|
||||||
super_t::operator=(other);
|
super_t::operator=(other);
|
||||||
|
|
||||||
// Is the interoperation of the stride safe?
|
// Is the interoperation of the stride safe?
|
||||||
m_stride = other.m_stride;
|
m_stride = other.m_stride;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment() { std::advance(this->base_reference(), m_stride); }
|
void increment() { std::advance(this->base_reference(), m_stride); }
|
||||||
|
|
||||||
void decrement() { std::advance(this->base_reference(), -m_stride); }
|
void decrement() { std::advance(this->base_reference(), -m_stride); }
|
||||||
|
|
||||||
void advance(difference_type n) { std::advance(this->base_reference(), n * m_stride); }
|
void advance(difference_type n) { std::advance(this->base_reference(), n * m_stride); }
|
||||||
|
|
||||||
difference_type
|
difference_type
|
||||||
distance_to(const strided_iterator& other) const
|
distance_to(const strided_iterator& other) const
|
||||||
{
|
{
|
||||||
return std::distance(this->base_reference(), other.base_reference()) / m_stride;
|
return std::distance(this->base_reference(), other.base_reference()) / m_stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Using the compiler generated copy constructor and
|
// Using the compiler generated copy constructor and
|
||||||
// and assignment operator
|
// and assignment operator
|
||||||
|
|
||||||
private:
|
private:
|
||||||
difference_type m_stride;
|
difference_type m_stride;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class BaseIterator> inline
|
template<class BaseIterator> inline
|
||||||
strided_iterator<BaseIterator>
|
strided_iterator<BaseIterator>
|
||||||
make_strided_iterator(
|
make_strided_iterator(
|
||||||
const BaseIterator& first,
|
const BaseIterator& first,
|
||||||
BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type stride)
|
BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type stride)
|
||||||
{
|
{
|
||||||
return strided_iterator<BaseIterator>(first, stride);
|
return strided_iterator<BaseIterator>(first, stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class Rng >
|
template< class Rng >
|
||||||
class strided_range
|
class strided_range
|
||||||
: public iterator_range<range_detail::strided_iterator<BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type> >
|
: public iterator_range<range_detail::strided_iterator<BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type> >
|
||||||
{
|
{
|
||||||
typedef range_detail::strided_iterator<BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type> iter_type;
|
typedef range_detail::strided_iterator<BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type> iter_type;
|
||||||
typedef iterator_range<iter_type> super_t;
|
typedef iterator_range<iter_type> super_t;
|
||||||
public:
|
public:
|
||||||
template< typename Difference >
|
template< typename Difference >
|
||||||
strided_range(Difference stride, Rng& rng)
|
strided_range(Difference stride, Rng& rng)
|
||||||
: super_t(make_strided_iterator(boost::begin(rng), stride),
|
: super_t(make_strided_iterator(boost::begin(rng), stride),
|
||||||
make_strided_iterator(boost::end(rng), stride))
|
make_strided_iterator(boost::end(rng), stride))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Difference>
|
template<class Difference>
|
||||||
class strided_holder : public holder<Difference>
|
class strided_holder : public holder<Difference>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
strided_holder(Difference value) : holder<Difference>(value) {}
|
strided_holder(Difference value) : holder<Difference>(value) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Rng, class Difference>
|
template<class Rng, class Difference>
|
||||||
inline strided_range<Rng>
|
inline strided_range<Rng>
|
||||||
operator|(Rng& rng, const strided_holder<Difference>& stride)
|
operator|(Rng& rng, const strided_holder<Difference>& stride)
|
||||||
{
|
{
|
||||||
return strided_range<Rng>(stride.val, rng);
|
return strided_range<Rng>(stride.val, rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Rng, class Difference>
|
template<class Rng, class Difference>
|
||||||
inline strided_range<const Rng>
|
inline strided_range<const Rng>
|
||||||
operator|(const Rng& rng, const strided_holder<Difference>& stride)
|
operator|(const Rng& rng, const strided_holder<Difference>& stride)
|
||||||
{
|
{
|
||||||
return strided_range<const Rng>(stride.val, rng);
|
return strided_range<const Rng>(stride.val, rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace range_detail
|
} // namespace range_detail
|
||||||
|
|
||||||
using range_detail::strided_range;
|
using range_detail::strided_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const range_detail::forwarder<range_detail::strided_holder>
|
const range_detail::forwarder<range_detail::strided_holder>
|
||||||
strided = range_detail::forwarder<range_detail::strided_holder>();
|
strided = range_detail::forwarder<range_detail::strided_holder>();
|
||||||
}
|
|
||||||
|
|
||||||
template<class Range, class Difference>
|
|
||||||
inline strided_range<Range>
|
|
||||||
stride(Range& rng, Difference step)
|
|
||||||
{
|
|
||||||
return strided_range<Range>(step, rng);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Range, class Difference>
|
|
||||||
inline strided_range<const Range>
|
|
||||||
stride(const Range& rng, Difference step)
|
|
||||||
{
|
|
||||||
return strided_range<const Range>(step, rng);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace 'adaptors'
|
template<class Range, class Difference>
|
||||||
|
inline strided_range<Range>
|
||||||
|
stride(Range& rng, Difference step)
|
||||||
|
{
|
||||||
|
return strided_range<Range>(step, rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Range, class Difference>
|
||||||
|
inline strided_range<const Range>
|
||||||
|
stride(const Range& rng, Difference step)
|
||||||
|
{
|
||||||
|
return strided_range<const Range>(step, rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace 'adaptors'
|
||||||
} // namespace 'boost'
|
} // namespace 'boost'
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,122 +16,122 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template< class R >
|
template< class R >
|
||||||
struct token_range :
|
struct token_range :
|
||||||
public boost::iterator_range<
|
public boost::iterator_range<
|
||||||
boost::regex_token_iterator<
|
boost::regex_token_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef
|
typedef
|
||||||
boost::regex_token_iterator<
|
boost::regex_token_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
regex_iter;
|
regex_iter;
|
||||||
|
|
||||||
typedef BOOST_DEDUCED_TYPENAME regex_iter::regex_type
|
typedef BOOST_DEDUCED_TYPENAME regex_iter::regex_type
|
||||||
regex_type;
|
regex_type;
|
||||||
|
|
||||||
typedef boost::iterator_range<regex_iter>
|
typedef boost::iterator_range<regex_iter>
|
||||||
base;
|
base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
template< class Regex, class Submatch, class Flag >
|
template< class Regex, class Submatch, class Flag >
|
||||||
token_range( R& r, const Regex& re, const Submatch& sub, Flag f )
|
token_range( R& r, const Regex& re, const Submatch& sub, Flag f )
|
||||||
: base( regex_iter( boost::begin(r), boost::end(r),
|
: base( regex_iter( boost::begin(r), boost::end(r),
|
||||||
regex_type(re), sub, f ),
|
regex_type(re), sub, f ),
|
||||||
regex_iter() )
|
regex_iter() )
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T, class U, class V >
|
template< class T, class U, class V >
|
||||||
struct regex_holder
|
struct regex_holder
|
||||||
{
|
{
|
||||||
const T& re;
|
const T& re;
|
||||||
const U& sub;
|
const U& sub;
|
||||||
V f;
|
V f;
|
||||||
|
|
||||||
regex_holder( const T& rex, const U& subm, V flag ) :
|
regex_holder( const T& rex, const U& subm, V flag ) :
|
||||||
re(rex), sub(subm), f(flag)
|
re(rex), sub(subm), f(flag)
|
||||||
{ }
|
{ }
|
||||||
private:
|
private:
|
||||||
// Not assignable
|
// Not assignable
|
||||||
void operator=(const regex_holder&);
|
void operator=(const regex_holder&);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct regex_forwarder
|
struct regex_forwarder
|
||||||
{
|
{
|
||||||
template< class Regex >
|
template< class Regex >
|
||||||
regex_holder<Regex,int,regex_constants::match_flag_type>
|
regex_holder<Regex,int,regex_constants::match_flag_type>
|
||||||
operator()( const Regex& re,
|
operator()( const Regex& re,
|
||||||
int submatch = 0,
|
int submatch = 0,
|
||||||
regex_constants::match_flag_type f =
|
regex_constants::match_flag_type f =
|
||||||
regex_constants::match_default ) const
|
regex_constants::match_default ) const
|
||||||
{
|
{
|
||||||
return regex_holder<Regex,int,
|
return regex_holder<Regex,int,
|
||||||
regex_constants::match_flag_type>( re, submatch, f );
|
regex_constants::match_flag_type>( re, submatch, f );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class Regex, class Submatch >
|
template< class Regex, class Submatch >
|
||||||
regex_holder<Regex,Submatch,regex_constants::match_flag_type>
|
regex_holder<Regex,Submatch,regex_constants::match_flag_type>
|
||||||
operator()( const Regex& re,
|
operator()( const Regex& re,
|
||||||
const Submatch& sub,
|
const Submatch& sub,
|
||||||
regex_constants::match_flag_type f =
|
regex_constants::match_flag_type f =
|
||||||
regex_constants::match_default ) const
|
regex_constants::match_default ) const
|
||||||
{
|
{
|
||||||
return regex_holder<Regex,Submatch,
|
return regex_holder<Regex,Submatch,
|
||||||
regex_constants::match_flag_type>( re, sub, f );
|
regex_constants::match_flag_type>( re, sub, f );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class BidirectionalRng, class R, class S, class F >
|
template< class BidirectionalRng, class R, class S, class F >
|
||||||
inline token_range<BidirectionalRng>
|
inline token_range<BidirectionalRng>
|
||||||
operator|( BidirectionalRng& r,
|
operator|( BidirectionalRng& r,
|
||||||
const regex_holder<R,S,F>& f )
|
const regex_holder<R,S,F>& f )
|
||||||
{
|
{
|
||||||
return token_range<BidirectionalRng>( r, f.re, f.sub, f.f );
|
return token_range<BidirectionalRng>( r, f.re, f.sub, f.f );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class BidirectionalRng, class R, class S, class F >
|
template< class BidirectionalRng, class R, class S, class F >
|
||||||
inline token_range<const BidirectionalRng>
|
inline token_range<const BidirectionalRng>
|
||||||
operator|( const BidirectionalRng& r,
|
operator|( const BidirectionalRng& r,
|
||||||
const regex_holder<R,S,F>& f )
|
const regex_holder<R,S,F>& f )
|
||||||
{
|
{
|
||||||
return token_range<const BidirectionalRng>( r, f.re, f.sub, f.f );
|
return token_range<const BidirectionalRng>( r, f.re, f.sub, f.f );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 'range_detail'
|
} // 'range_detail'
|
||||||
|
|
||||||
using range_detail::token_range;
|
using range_detail::token_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const range_detail::regex_forwarder tokenized =
|
const range_detail::regex_forwarder tokenized =
|
||||||
range_detail::regex_forwarder();
|
range_detail::regex_forwarder();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class BidirectionalRange, class Regex, class Submatch, class Flag>
|
template<class BidirectionalRange, class Regex, class Submatch, class Flag>
|
||||||
inline token_range<BidirectionalRange>
|
inline token_range<BidirectionalRange>
|
||||||
tokenize(BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f)
|
tokenize(BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f)
|
||||||
{
|
{
|
||||||
return token_range<BidirectionalRange>(rng, reg, sub, f);
|
return token_range<BidirectionalRange>(rng, reg, sub, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class BidirectionalRange, class Regex, class Submatch, class Flag>
|
template<class BidirectionalRange, class Regex, class Submatch, class Flag>
|
||||||
inline token_range<const BidirectionalRange>
|
inline token_range<const BidirectionalRange>
|
||||||
tokenize(const BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f)
|
tokenize(const BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f)
|
||||||
{
|
{
|
||||||
return token_range<const BidirectionalRange>(rng, reg, sub, f);
|
return token_range<const BidirectionalRange>(rng, reg, sub, f);
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
} // 'adaptors'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,87 +17,87 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template< class F, class R >
|
template< class F, class R >
|
||||||
struct transform_range :
|
struct transform_range :
|
||||||
public boost::iterator_range<
|
public boost::iterator_range<
|
||||||
boost::transform_iterator< F,
|
boost::transform_iterator< F,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
typedef boost::iterator_range<
|
typedef boost::iterator_range<
|
||||||
boost::transform_iterator< F,
|
boost::transform_iterator< F,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
base;
|
base;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef F transform_fn_type;
|
typedef F transform_fn_type;
|
||||||
typedef R source_range_type;
|
typedef R source_range_type;
|
||||||
|
|
||||||
transform_range( F f, R& r )
|
transform_range( F f, R& r )
|
||||||
: base( make_transform_iterator( boost::begin(r), f ),
|
: base( make_transform_iterator( boost::begin(r), f ),
|
||||||
make_transform_iterator( boost::end(r), f ) )
|
make_transform_iterator( boost::end(r), f ) )
|
||||||
|
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
struct transform_holder : holder<T>
|
struct transform_holder : holder<T>
|
||||||
{
|
{
|
||||||
transform_holder( T r ) : holder<T>(r)
|
transform_holder( T r ) : holder<T>(r)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class InputRng, class UnaryFunction >
|
template< class InputRng, class UnaryFunction >
|
||||||
inline transform_range<UnaryFunction,InputRng>
|
inline transform_range<UnaryFunction,InputRng>
|
||||||
operator|( InputRng& r,
|
operator|( InputRng& r,
|
||||||
const transform_holder<UnaryFunction>& f )
|
const transform_holder<UnaryFunction>& f )
|
||||||
{
|
{
|
||||||
return transform_range<UnaryFunction,InputRng>( f.val, r );
|
return transform_range<UnaryFunction,InputRng>( f.val, r );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class InputRng, class UnaryFunction >
|
template< class InputRng, class UnaryFunction >
|
||||||
inline transform_range<UnaryFunction, const InputRng>
|
inline transform_range<UnaryFunction, const InputRng>
|
||||||
operator|( const InputRng& r,
|
operator|( const InputRng& r,
|
||||||
const transform_holder<UnaryFunction>& f )
|
const transform_holder<UnaryFunction>& f )
|
||||||
{
|
{
|
||||||
return transform_range<UnaryFunction, const InputRng>( f.val, r );
|
return transform_range<UnaryFunction, const InputRng>( f.val, r );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // 'range_detail'
|
} // 'range_detail'
|
||||||
|
|
||||||
using range_detail::transform_range;
|
using range_detail::transform_range;
|
||||||
|
|
||||||
namespace adaptors
|
namespace adaptors
|
||||||
{
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const range_detail::forwarder<range_detail::transform_holder>
|
const range_detail::forwarder<range_detail::transform_holder>
|
||||||
transformed =
|
transformed =
|
||||||
range_detail::forwarder<range_detail::transform_holder>();
|
range_detail::forwarder<range_detail::transform_holder>();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class UnaryFunction, class InputRange>
|
template<class UnaryFunction, class InputRange>
|
||||||
inline transform_range<UnaryFunction, InputRange>
|
inline transform_range<UnaryFunction, InputRange>
|
||||||
transform(InputRange& rng, UnaryFunction fn)
|
transform(InputRange& rng, UnaryFunction fn)
|
||||||
{
|
{
|
||||||
return transform_range<UnaryFunction, InputRange>(fn, rng);
|
return transform_range<UnaryFunction, InputRange>(fn, rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class UnaryFunction, class InputRange>
|
template<class UnaryFunction, class InputRange>
|
||||||
inline transform_range<UnaryFunction, const InputRange>
|
inline transform_range<UnaryFunction, const InputRange>
|
||||||
transform(const InputRange& rng, UnaryFunction fn)
|
transform(const InputRange& rng, UnaryFunction fn)
|
||||||
{
|
{
|
||||||
return transform_range<UnaryFunction, const InputRange>(fn, rng);
|
return transform_range<UnaryFunction, const InputRange>(fn, rng);
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
} // 'adaptors'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,74 +16,74 @@
|
|||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
struct unique_forwarder { };
|
struct unique_forwarder { };
|
||||||
|
|
||||||
struct unique_not_equal_to
|
struct unique_not_equal_to
|
||||||
{
|
{
|
||||||
typedef bool result_type;
|
typedef bool result_type;
|
||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
bool operator()( const T& l, const T& r ) const
|
bool operator()( const T& l, const T& r ) const
|
||||||
{
|
{
|
||||||
return !(l == r);
|
return !(l == r);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class ForwardRng>
|
template<class ForwardRng>
|
||||||
class unique_range : public adjacent_filter_range<unique_not_equal_to, ForwardRng, true>
|
class unique_range : public adjacent_filter_range<unique_not_equal_to, ForwardRng, true>
|
||||||
{
|
{
|
||||||
typedef adjacent_filter_range<unique_not_equal_to, ForwardRng, true> base;
|
typedef adjacent_filter_range<unique_not_equal_to, ForwardRng, true> base;
|
||||||
public:
|
public:
|
||||||
explicit unique_range(ForwardRng& rng)
|
explicit unique_range(ForwardRng& rng)
|
||||||
: base(unique_not_equal_to(), rng)
|
: base(unique_not_equal_to(), rng)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class ForwardRng >
|
template< class ForwardRng >
|
||||||
inline unique_range<ForwardRng>
|
inline unique_range<ForwardRng>
|
||||||
operator|( ForwardRng& r,
|
operator|( ForwardRng& r,
|
||||||
unique_forwarder )
|
unique_forwarder )
|
||||||
{
|
{
|
||||||
return unique_range<ForwardRng>(r);
|
return unique_range<ForwardRng>(r);
|
||||||
}
|
|
||||||
|
|
||||||
template< class ForwardRng >
|
|
||||||
inline unique_range<const ForwardRng>
|
|
||||||
operator|( const ForwardRng& r,
|
|
||||||
unique_forwarder )
|
|
||||||
{
|
|
||||||
return unique_range<const ForwardRng>(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // 'range_detail'
|
|
||||||
|
|
||||||
using range_detail::unique_range;
|
|
||||||
|
|
||||||
namespace adaptors
|
|
||||||
{
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
const range_detail::unique_forwarder uniqued =
|
|
||||||
range_detail::unique_forwarder();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ForwardRange>
|
|
||||||
inline unique_range<ForwardRange>
|
|
||||||
unique(ForwardRange& rng)
|
|
||||||
{
|
|
||||||
return unique_range<ForwardRange>(rng);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class ForwardRange>
|
|
||||||
inline unique_range<const ForwardRange>
|
|
||||||
unique(const ForwardRange& rng)
|
|
||||||
{
|
|
||||||
return unique_range<const ForwardRange>(rng);
|
|
||||||
}
|
}
|
||||||
} // 'adaptors'
|
|
||||||
|
template< class ForwardRng >
|
||||||
|
inline unique_range<const ForwardRng>
|
||||||
|
operator|( const ForwardRng& r,
|
||||||
|
unique_forwarder )
|
||||||
|
{
|
||||||
|
return unique_range<const ForwardRng>(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // 'range_detail'
|
||||||
|
|
||||||
|
using range_detail::unique_range;
|
||||||
|
|
||||||
|
namespace adaptors
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
const range_detail::unique_forwarder uniqued =
|
||||||
|
range_detail::unique_forwarder();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ForwardRange>
|
||||||
|
inline unique_range<ForwardRange>
|
||||||
|
unique(ForwardRange& rng)
|
||||||
|
{
|
||||||
|
return unique_range<ForwardRange>(rng);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class ForwardRange>
|
||||||
|
inline unique_range<const ForwardRange>
|
||||||
|
unique(const ForwardRange& rng)
|
||||||
|
{
|
||||||
|
return unique_range<const ForwardRange>(rng);
|
||||||
|
}
|
||||||
|
} // 'adaptors'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace boost
|
|||||||
{
|
{
|
||||||
// An implementation of equality comparison that is optimized for iterator
|
// An implementation of equality comparison that is optimized for iterator
|
||||||
// traversal categories less than RandomAccessTraversal.
|
// traversal categories less than RandomAccessTraversal.
|
||||||
template< class SinglePassTraversalReadableIterator1,
|
template< class SinglePassTraversalReadableIterator1,
|
||||||
class SinglePassTraversalReadableIterator2,
|
class SinglePassTraversalReadableIterator2,
|
||||||
class IteratorCategoryTag1,
|
class IteratorCategoryTag1,
|
||||||
class IteratorCategoryTag2 >
|
class IteratorCategoryTag2 >
|
||||||
|
@ -31,7 +31,7 @@ namespace boost
|
|||||||
remove_copy_if(SinglePassRange& rng, OutputIterator out_it, Predicate pred)
|
remove_copy_if(SinglePassRange& rng, OutputIterator out_it, Predicate pred)
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
||||||
return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred);
|
return std::remove_copy_if(boost::begin(rng), boost::end(rng), out_it, pred);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,55 +19,55 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
template<class InputIterator1, class InputIterator2, class Fn2>
|
template<class InputIterator1, class InputIterator2, class Fn2>
|
||||||
inline Fn2 for_each_impl(InputIterator1 first1, InputIterator1 last1,
|
inline Fn2 for_each_impl(InputIterator1 first1, InputIterator1 last1,
|
||||||
InputIterator2 first2, InputIterator2 last2,
|
InputIterator2 first2, InputIterator2 last2,
|
||||||
Fn2 fn)
|
Fn2 fn)
|
||||||
{
|
{
|
||||||
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
|
for (; first1 != last1 && first2 != last2; ++first1, ++first2)
|
||||||
{
|
{
|
||||||
fn(*first1, *first2);
|
fn(*first1, *first2);
|
||||||
}
|
}
|
||||||
return fn;
|
return fn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace range
|
namespace range
|
||||||
{
|
{
|
||||||
template<class SinglePassRange1, class SinglePassRange2, class Fn2>
|
template<class SinglePassRange1, class SinglePassRange2, class Fn2>
|
||||||
inline Fn2 for_each(const SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn)
|
inline Fn2 for_each(const SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn)
|
||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
|
||||||
|
|
||||||
return ::boost::range_detail::for_each_impl(
|
return ::boost::range_detail::for_each_impl(
|
||||||
::boost::begin(rng1), ::boost::end(rng1),
|
::boost::begin(rng1), ::boost::end(rng1),
|
||||||
::boost::begin(rng2), ::boost::end(rng2), fn);
|
::boost::begin(rng2), ::boost::end(rng2), fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SinglePassRange1, class SinglePassRange2, class Fn2>
|
template<class SinglePassRange1, class SinglePassRange2, class Fn2>
|
||||||
inline Fn2 for_each(const SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn)
|
inline Fn2 for_each(const SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn)
|
||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
|
||||||
|
|
||||||
return ::boost::range_detail::for_each_impl(
|
return ::boost::range_detail::for_each_impl(
|
||||||
::boost::begin(rng1), ::boost::end(rng1),
|
::boost::begin(rng1), ::boost::end(rng1),
|
||||||
::boost::begin(rng2), ::boost::end(rng2), fn);
|
::boost::begin(rng2), ::boost::end(rng2), fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SinglePassRange1, class SinglePassRange2, class Fn2>
|
template<class SinglePassRange1, class SinglePassRange2, class Fn2>
|
||||||
inline Fn2 for_each(SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn)
|
inline Fn2 for_each(SinglePassRange1& rng1, const SinglePassRange2& rng2, Fn2 fn)
|
||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
|
||||||
|
|
||||||
return ::boost::range_detail::for_each_impl(
|
return ::boost::range_detail::for_each_impl(
|
||||||
::boost::begin(rng1), ::boost::end(rng1),
|
::boost::begin(rng1), ::boost::end(rng1),
|
||||||
::boost::begin(rng2), ::boost::end(rng2), fn);
|
::boost::begin(rng2), ::boost::end(rng2), fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SinglePassRange1, class SinglePassRange2, class Fn2>
|
template<class SinglePassRange1, class SinglePassRange2, class Fn2>
|
||||||
inline Fn2 for_each(SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn)
|
inline Fn2 for_each(SinglePassRange1& rng1, SinglePassRange2& rng2, Fn2 fn)
|
||||||
@ -79,8 +79,8 @@ namespace boost
|
|||||||
::boost::begin(rng1), ::boost::end(rng1),
|
::boost::begin(rng1), ::boost::end(rng1),
|
||||||
::boost::begin(rng2), ::boost::end(rng2), fn);
|
::boost::begin(rng2), ::boost::end(rng2), fn);
|
||||||
}
|
}
|
||||||
} // namespace range
|
} // namespace range
|
||||||
using range::for_each;
|
using range::for_each;
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
@ -25,41 +25,41 @@
|
|||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class Value>
|
template<class Value>
|
||||||
inline iterator_range<counting_iterator<Value> >
|
inline iterator_range<counting_iterator<Value> >
|
||||||
counting_range(Value first, Value last)
|
counting_range(Value first, Value last)
|
||||||
{
|
{
|
||||||
typedef counting_iterator<Value> counting_iterator_t;
|
typedef counting_iterator<Value> counting_iterator_t;
|
||||||
typedef iterator_range<counting_iterator_t> result_t;
|
typedef iterator_range<counting_iterator_t> result_t;
|
||||||
return result_t(counting_iterator_t(first),
|
return result_t(counting_iterator_t(first),
|
||||||
counting_iterator_t(last));
|
counting_iterator_t(last));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Range>
|
template<class Range>
|
||||||
inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> >
|
inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> >
|
||||||
counting_range(const Range& rng)
|
counting_range(const Range& rng)
|
||||||
{
|
{
|
||||||
typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> counting_iterator_t;
|
typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> counting_iterator_t;
|
||||||
typedef iterator_range<counting_iterator_t> result_t;
|
typedef iterator_range<counting_iterator_t> result_t;
|
||||||
return boost::empty(rng)
|
return boost::empty(rng)
|
||||||
? result_t()
|
? result_t()
|
||||||
: result_t(
|
: result_t(
|
||||||
counting_iterator_t(*boost::begin(rng)),
|
counting_iterator_t(*boost::begin(rng)),
|
||||||
counting_iterator_t(*boost::prior(boost::end(rng))));
|
counting_iterator_t(*boost::prior(boost::end(rng))));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Range>
|
template<class Range>
|
||||||
inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> >
|
inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> >
|
||||||
counting_range(Range& rng)
|
counting_range(Range& rng)
|
||||||
{
|
{
|
||||||
typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> counting_iterator_t;
|
typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> counting_iterator_t;
|
||||||
typedef iterator_range<counting_iterator_t> result_t;
|
typedef iterator_range<counting_iterator_t> result_t;
|
||||||
return boost::empty(rng)
|
return boost::empty(rng)
|
||||||
? result_t()
|
? result_t()
|
||||||
: result_t(
|
: result_t(
|
||||||
counting_iterator_t(*boost::begin(rng)),
|
counting_iterator_t(*boost::begin(rng)),
|
||||||
counting_iterator_t(*boost::prior(boost::end(rng))));
|
counting_iterator_t(*boost::prior(boost::end(rng))));
|
||||||
}
|
}
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#if BOOST_MSVC >= 1400
|
#if BOOST_MSVC >= 1400
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace range_detail
|
namespace range_detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class IteratorTraversalTag1, class IteratorTraversalTag2>
|
template<class IteratorTraversalTag1, class IteratorTraversalTag2>
|
||||||
struct demote_iterator_traversal_tag
|
struct demote_iterator_traversal_tag
|
||||||
@ -26,7 +26,7 @@ struct demote_iterator_traversal_tag
|
|||||||
#define BOOST_DEMOTE_TRAVERSAL_TAG( Tag1, Tag2, ResultTag ) \
|
#define BOOST_DEMOTE_TRAVERSAL_TAG( Tag1, Tag2, ResultTag ) \
|
||||||
template<> struct demote_iterator_traversal_tag< Tag1 , Tag2 > \
|
template<> struct demote_iterator_traversal_tag< Tag1 , Tag2 > \
|
||||||
{ \
|
{ \
|
||||||
typedef ResultTag type; \
|
typedef ResultTag type; \
|
||||||
};
|
};
|
||||||
|
|
||||||
BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, no_traversal_tag, no_traversal_tag )
|
BOOST_DEMOTE_TRAVERSAL_TAG( no_traversal_tag, no_traversal_tag, no_traversal_tag )
|
||||||
@ -73,7 +73,7 @@ BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, random_access_traversal
|
|||||||
|
|
||||||
#undef BOOST_DEMOTE_TRAVERSAL_TAG
|
#undef BOOST_DEMOTE_TRAVERSAL_TAG
|
||||||
|
|
||||||
} // namespace range_detail
|
} // namespace range_detail
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
@ -21,46 +21,46 @@ namespace boost
|
|||||||
|
|
||||||
template<class SinglePassRange1, class SinglePassRange2>
|
template<class SinglePassRange1, class SinglePassRange2>
|
||||||
iterator_range<range_detail::join_iterator<
|
iterator_range<range_detail::join_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type,
|
||||||
BOOST_DEDUCED_TYPENAME add_const<
|
BOOST_DEDUCED_TYPENAME add_const<
|
||||||
BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange1>::type>::type>
|
BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange1>::type>::type>
|
||||||
>
|
>
|
||||||
join(const SinglePassRange1& r1, const SinglePassRange2& r2)
|
join(const SinglePassRange1& r1, const SinglePassRange2& r2)
|
||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
|
||||||
|
|
||||||
typedef range_detail::join_iterator<
|
typedef range_detail::join_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange1>::type,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange2>::type,
|
||||||
BOOST_DEDUCED_TYPENAME add_const<
|
BOOST_DEDUCED_TYPENAME add_const<
|
||||||
BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange1>::type>::type> iterator_t;
|
BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange1>::type>::type> iterator_t;
|
||||||
|
|
||||||
return iterator_range<iterator_t>(
|
return iterator_range<iterator_t>(
|
||||||
iterator_t(r1, r2, range_detail::join_iterator_begin_tag()),
|
iterator_t(r1, r2, range_detail::join_iterator_begin_tag()),
|
||||||
iterator_t(r1, r2, range_detail::join_iterator_end_tag()));
|
iterator_t(r1, r2, range_detail::join_iterator_end_tag()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class SinglePassRange1, class SinglePassRange2>
|
template<class SinglePassRange1, class SinglePassRange2>
|
||||||
iterator_range<range_detail::join_iterator<
|
iterator_range<range_detail::join_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type,
|
||||||
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange1>::type>
|
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange1>::type>
|
||||||
>
|
>
|
||||||
join(SinglePassRange1& r1, SinglePassRange2& r2)
|
join(SinglePassRange1& r1, SinglePassRange2& r2)
|
||||||
{
|
{
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange1> ));
|
||||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
|
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange2> ));
|
||||||
|
|
||||||
typedef range_detail::join_iterator<
|
typedef range_detail::join_iterator<
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange1>::type,
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type,
|
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange2>::type,
|
||||||
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange1>::type> iterator_t;
|
BOOST_DEDUCED_TYPENAME range_value<SinglePassRange1>::type> iterator_t;
|
||||||
|
|
||||||
return iterator_range<iterator_t>(
|
return iterator_range<iterator_t>(
|
||||||
iterator_t(r1, r2, range_detail::join_iterator_begin_tag()),
|
iterator_t(r1, r2, range_detail::join_iterator_begin_tag()),
|
||||||
iterator_t(r1, r2, range_detail::join_iterator_end_tag()));
|
iterator_t(r1, r2, range_detail::join_iterator_end_tag()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#if defined(_MSC_VER) && _MSC_VER >= 1000
|
#if defined(_MSC_VER) && _MSC_VER >= 1000
|
||||||
#pragma once
|
#pragma once
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef BOOST_RANGE_NUMERIC_HPP
|
#ifndef BOOST_RANGE_NUMERIC_HPP
|
||||||
@ -36,82 +36,82 @@
|
|||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
template< class SinglePassRange, class Value >
|
template< class SinglePassRange, class Value >
|
||||||
inline Value accumulate( const SinglePassRange& rng, Value init )
|
inline Value accumulate( const SinglePassRange& rng, Value init )
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
||||||
return std::accumulate( boost::begin(rng), boost::end(rng), init );
|
return std::accumulate( boost::begin(rng), boost::end(rng), init );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class SinglePassRange, class Value, class BinaryOperation >
|
template< class SinglePassRange, class Value, class BinaryOperation >
|
||||||
inline Value accumulate( const SinglePassRange& rng, Value init, BinaryOperation op )
|
inline Value accumulate( const SinglePassRange& rng, Value init, BinaryOperation op )
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
||||||
return std::accumulate( boost::begin(rng), boost::end(rng), init, op );
|
return std::accumulate( boost::begin(rng), boost::end(rng), init, op );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template< class SinglePassRange1, class SinglePassRange2, class Value >
|
template< class SinglePassRange1, class SinglePassRange2, class Value >
|
||||||
inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, Value init )
|
inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, Value init )
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
|
||||||
BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) );
|
BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) );
|
||||||
return std::inner_product( boost::begin(rng1), boost::end(rng1),
|
return std::inner_product( boost::begin(rng1), boost::end(rng1),
|
||||||
boost::begin(rng2), init );
|
boost::begin(rng2), init );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class SinglePassRange1,
|
template< class SinglePassRange1,
|
||||||
class SinglePassRange2,
|
class SinglePassRange2,
|
||||||
class Value,
|
class Value,
|
||||||
class BinaryOperation1, class BinaryOperation2 >
|
class BinaryOperation1, class BinaryOperation2 >
|
||||||
inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
||||||
Value init,
|
Value init,
|
||||||
BinaryOperation1 op1, BinaryOperation2 op2 )
|
BinaryOperation1 op1, BinaryOperation2 op2 )
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange1> >();
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange2> >();
|
||||||
BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) );
|
BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) );
|
||||||
|
|
||||||
return std::inner_product( boost::begin(rng1), boost::end(rng1),
|
return std::inner_product( boost::begin(rng1), boost::end(rng1),
|
||||||
boost::begin(rng2), init, op1, op2 );
|
boost::begin(rng2), init, op1, op2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class SinglePassRange, class OutputIterator >
|
template< class SinglePassRange, class OutputIterator >
|
||||||
inline OutputIterator partial_sum ( const SinglePassRange& rng,
|
inline OutputIterator partial_sum ( const SinglePassRange& rng,
|
||||||
OutputIterator result )
|
OutputIterator result )
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
||||||
return std::partial_sum( boost::begin(rng), boost::end(rng), result );
|
return std::partial_sum( boost::begin(rng), boost::end(rng), result );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class SinglePassRange, class OutputIterator, class BinaryOperation >
|
template< class SinglePassRange, class OutputIterator, class BinaryOperation >
|
||||||
inline OutputIterator partial_sum ( const SinglePassRange& rng, OutputIterator result,
|
inline OutputIterator partial_sum ( const SinglePassRange& rng, OutputIterator result,
|
||||||
BinaryOperation op )
|
BinaryOperation op )
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
||||||
return std::partial_sum( boost::begin(rng), boost::end(rng), result, op );
|
return std::partial_sum( boost::begin(rng), boost::end(rng), result, op );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class SinglePassRange, class OutputIterator >
|
template< class SinglePassRange, class OutputIterator >
|
||||||
inline OutputIterator adjacent_difference ( const SinglePassRange& rng,
|
inline OutputIterator adjacent_difference ( const SinglePassRange& rng,
|
||||||
OutputIterator result )
|
OutputIterator result )
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
||||||
return std::adjacent_difference( boost::begin(rng), boost::end(rng),
|
return std::adjacent_difference( boost::begin(rng), boost::end(rng),
|
||||||
result );
|
result );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class SinglePassRange, class OutputIterator, class BinaryOperation >
|
template< class SinglePassRange, class OutputIterator, class BinaryOperation >
|
||||||
inline OutputIterator adjacent_difference ( const SinglePassRange& rng,
|
inline OutputIterator adjacent_difference ( const SinglePassRange& rng,
|
||||||
OutputIterator result,
|
OutputIterator result,
|
||||||
BinaryOperation op )
|
BinaryOperation op )
|
||||||
{
|
{
|
||||||
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
boost::function_requires< SinglePassRangeConcept<SinglePassRange> >();
|
||||||
return std::adjacent_difference( boost::begin(rng), boost::end(rng),
|
return std::adjacent_difference( boost::begin(rng), boost::end(rng),
|
||||||
result, op );
|
result, op );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -68,7 +68,7 @@ namespace boost
|
|||||||
|
|
||||||
template< class T >
|
template< class T >
|
||||||
struct range_size<const T >
|
struct range_size<const T >
|
||||||
: detail::range_size<T>
|
: detail::range_size<T>
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
@ -55,4 +55,4 @@ init_unit_test_suite(int argc, char* argv[])
|
|||||||
test->add( BOOST_TEST_CASE( &adjacent_filtered_example_test ) );
|
test->add( BOOST_TEST_CASE( &adjacent_filtered_example_test ) );
|
||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
@ -55,4 +55,4 @@ init_unit_test_suite(int argc, char* argv[])
|
|||||||
test->add( BOOST_TEST_CASE( &copied_example_test ) );
|
test->add( BOOST_TEST_CASE( &copied_example_test ) );
|
||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
@ -36,16 +36,16 @@ namespace boost
|
|||||||
return boost::find(cont, 3);
|
return boost::find(cont, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value return_type>
|
template<range_return_value return_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy&, Container& cont)
|
operator()(Policy&, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::find<return_type>(cont, 3);
|
return boost::find<return_type>(cont, 3);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
||||||
|
@ -35,7 +35,7 @@ namespace boost
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
container2_t cont() { return m_cont; }
|
container2_t cont() { return m_cont; }
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
||||||
@ -45,14 +45,14 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value return_type>
|
template<range_return_value return_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::find_end<return_type>(cont, policy.cont());
|
return boost::find_end<return_type>(cont, policy.cont());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
@ -77,8 +77,8 @@ namespace boost
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
container2_t& cont() { return m_cont; }
|
container2_t& cont() { return m_cont; }
|
||||||
BinaryPredicate& pred() { return m_pred; }
|
BinaryPredicate& pred() { return m_pred; }
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
||||||
@ -88,14 +88,14 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value return_type>
|
template<range_return_value return_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::find_end<return_type>(cont, policy.cont(), policy.pred());
|
return boost::find_end<return_type>(cont, policy.cont(), policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
|
@ -35,7 +35,7 @@ namespace boost
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
container2_t& cont() { return m_cont; }
|
container2_t& cont() { return m_cont; }
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
||||||
@ -45,14 +45,14 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value return_type>
|
template<range_return_value return_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::find_first_of<return_type>(cont, policy.cont());
|
return boost::find_first_of<return_type>(cont, policy.cont());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
@ -77,8 +77,8 @@ namespace boost
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
container2_t& cont() { return m_cont; }
|
container2_t& cont() { return m_cont; }
|
||||||
BinaryPredicate& pred() { return m_pred; }
|
BinaryPredicate& pred() { return m_pred; }
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
||||||
@ -88,14 +88,14 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value return_type>
|
template<range_return_value return_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::find_first_of<return_type>(cont, policy.cont(), policy.pred());
|
return boost::find_first_of<return_type>(cont, policy.cont(), policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
|
@ -41,15 +41,15 @@ namespace boost
|
|||||||
return boost::find_if(cont, m_pred);
|
return boost::find_if(cont, m_pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value return_type>
|
template<range_return_value return_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container>
|
template<class Container>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(find_if_test_policy& policy, Container& cont)
|
operator()(find_if_test_policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::find_if<return_type>(cont, policy.pred());
|
return boost::find_if<return_type>(cont, policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
@ -59,7 +59,7 @@ namespace boost
|
|||||||
return std::find_if(cont.begin(), cont.end(), m_pred);
|
return std::find_if(cont.begin(), cont.end(), m_pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnaryPredicate& pred() { return m_pred; }
|
UnaryPredicate& pred() { return m_pred; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UnaryPredicate m_pred;
|
UnaryPredicate m_pred;
|
||||||
|
@ -83,4 +83,4 @@ init_unit_test_suite(int argc, char* argv[])
|
|||||||
test->add( BOOST_TEST_CASE( &boost::test_for_each ) );
|
test->add( BOOST_TEST_CASE( &boost::test_for_each ) );
|
||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
@ -36,16 +36,16 @@ namespace boost
|
|||||||
return boost::lower_bound(cont, 5);
|
return boost::lower_bound(cont, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value return_type>
|
template<range_return_value return_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy&, Container& cont)
|
operator()(Policy&, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::lower_bound<return_type>(cont, 5);
|
return boost::lower_bound<return_type>(cont, 5);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
||||||
@ -66,15 +66,15 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< range_return_value return_type >
|
template< range_return_value return_type >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::lower_bound<return_type>(
|
return boost::lower_bound<return_type>(
|
||||||
cont, 5, policy.pred());
|
cont, 5, policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
@ -85,10 +85,10 @@ namespace boost
|
|||||||
cont.begin(), cont.end(), 5, m_pred);
|
cont.begin(), cont.end(), 5, m_pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryPredicate& pred() { return m_pred; }
|
BinaryPredicate& pred() { return m_pred; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BinaryPredicate m_pred;
|
BinaryPredicate m_pred;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container,
|
template<class Container,
|
||||||
|
@ -37,14 +37,14 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value return_type>
|
template<range_return_value return_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy&, Container& cont)
|
operator()(Policy&, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::max_element<return_type>(cont);
|
return boost::max_element<return_type>(cont);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
@ -66,17 +66,17 @@ namespace boost
|
|||||||
return boost::max_element(cont, Pred());
|
return boost::max_element(cont, Pred());
|
||||||
}
|
}
|
||||||
|
|
||||||
Pred pred() const { return Pred(); }
|
Pred pred() const { return Pred(); }
|
||||||
|
|
||||||
template< range_return_value return_type >
|
template< range_return_value return_type >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template< class Container, class Policy >
|
template< class Container, class Policy >
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::max_element<return_type>(cont, policy.pred());
|
return boost::max_element<return_type>(cont, policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
|
@ -37,14 +37,14 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< range_return_value return_type >
|
template< range_return_value return_type >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template< class Container, class Policy >
|
template< class Container, class Policy >
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy&, Container& cont)
|
operator()(Policy&, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::min_element<return_type>(cont);
|
return boost::min_element<return_type>(cont);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
@ -66,17 +66,17 @@ namespace boost
|
|||||||
return boost::min_element(cont, Pred());
|
return boost::min_element(cont, Pred());
|
||||||
}
|
}
|
||||||
|
|
||||||
Pred pred() const { return Pred(); }
|
Pred pred() const { return Pred(); }
|
||||||
|
|
||||||
template< range_return_value return_type >
|
template< range_return_value return_type >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template< class Container, class Policy >
|
template< class Container, class Policy >
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::min_element<return_type>(cont, policy.pred());
|
return boost::min_element<return_type>(cont, policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
|
@ -44,17 +44,17 @@ namespace boost
|
|||||||
return boost::partition(cont, UnaryPredicate());
|
return boost::partition(cont, UnaryPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
UnaryPredicate pred() const { return UnaryPredicate(); }
|
UnaryPredicate pred() const { return UnaryPredicate(); }
|
||||||
|
|
||||||
template< range_return_value return_type >
|
template< range_return_value return_type >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template< class Container, class Policy >
|
template< class Container, class Policy >
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::partition<return_type>(cont, policy.pred());
|
return boost::partition<return_type>(cont, policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
|
@ -44,17 +44,17 @@ namespace boost
|
|||||||
return boost::stable_partition(cont, UnaryPredicate());
|
return boost::stable_partition(cont, UnaryPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
UnaryPredicate pred() const { return UnaryPredicate(); }
|
UnaryPredicate pred() const { return UnaryPredicate(); }
|
||||||
|
|
||||||
template< range_return_value return_type >
|
template< range_return_value return_type >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template< class Container, class Policy >
|
template< class Container, class Policy >
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::stable_partition<return_type>(cont, policy.pred());
|
return boost::stable_partition<return_type>(cont, policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
|
@ -41,14 +41,14 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< range_return_value return_type >
|
template< range_return_value return_type >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template< class Container, class Policy >
|
template< class Container, class Policy >
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy&, Container& cont)
|
operator()(Policy&, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::unique<return_type>(cont);
|
return boost::unique<return_type>(cont);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
@ -73,17 +73,17 @@ namespace boost
|
|||||||
return std::unique(cont.begin(), cont.end(), Pred());
|
return std::unique(cont.begin(), cont.end(), Pred());
|
||||||
}
|
}
|
||||||
|
|
||||||
Pred pred() const { return Pred(); }
|
Pred pred() const { return Pred(); }
|
||||||
|
|
||||||
template< range_return_value return_type >
|
template< range_return_value return_type >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template< class Container, class Policy >
|
template< class Container, class Policy >
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,return_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::unique<return_type>(cont, policy.pred());
|
return boost::unique<return_type>(cont, policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
|
@ -35,16 +35,16 @@ namespace boost
|
|||||||
return boost::upper_bound(cont, 5);
|
return boost::upper_bound(cont, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<range_return_value result_type>
|
template<range_return_value result_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template<class Container, class Policy>
|
template<class Container, class Policy>
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,result_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,result_type>::type
|
||||||
operator()(Policy&, Container& cont)
|
operator()(Policy&, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::upper_bound<result_type>(cont, 5);
|
return boost::upper_bound<result_type>(cont, 5);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class Container >
|
template< class Container >
|
||||||
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
BOOST_DEDUCED_TYPENAME range_iterator<Container>::type
|
||||||
@ -65,15 +65,15 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template< range_return_value result_type>
|
template< range_return_value result_type>
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
template< class Container, class Policy >
|
template< class Container, class Policy >
|
||||||
BOOST_DEDUCED_TYPENAME range_return<Container,result_type>::type
|
BOOST_DEDUCED_TYPENAME range_return<Container,result_type>::type
|
||||||
operator()(Policy& policy, Container& cont)
|
operator()(Policy& policy, Container& cont)
|
||||||
{
|
{
|
||||||
return boost::upper_bound<result_type>(
|
return boost::upper_bound<result_type>(
|
||||||
cont, 5, policy.pred());
|
cont, 5, policy.pred());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container>
|
template<class Container>
|
||||||
@ -83,11 +83,11 @@ namespace boost
|
|||||||
return std::upper_bound(
|
return std::upper_bound(
|
||||||
cont.begin(), cont.end(), 5, BinaryPredicate());
|
cont.begin(), cont.end(), 5, BinaryPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
BinaryPredicate& pred() { return m_pred; }
|
BinaryPredicate& pred() { return m_pred; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BinaryPredicate m_pred;
|
BinaryPredicate m_pred;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Container,
|
template<class Container,
|
||||||
|
@ -70,4 +70,4 @@ init_unit_test_suite(int argc, char* argv[])
|
|||||||
test->add( BOOST_TEST_CASE( &boost::counting_range_test ) );
|
test->add( BOOST_TEST_CASE( &boost::counting_range_test ) );
|
||||||
|
|
||||||
return test;
|
return test;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ void check_iterator_range()
|
|||||||
BOOST_CHECK_EQUAL( r2.size(), size( r2 ) );
|
BOOST_CHECK_EQUAL( r2.size(), size( r2 ) );
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL( std::distance( r.begin(), r.end() ),
|
BOOST_CHECK_EQUAL( std::distance( r.begin(), r.end() ),
|
||||||
std::distance( boost::begin( r2 ), boost::end( r2 ) ) );
|
std::distance( boost::begin( r2 ), boost::end( r2 ) ) );
|
||||||
std::cout << r << r2;
|
std::cout << r << r2;
|
||||||
|
|
||||||
|
|
||||||
|
@ -379,25 +379,25 @@ namespace boost
|
|||||||
range_result, reference_it);
|
range_result, reference_it);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< range_return_value result_type, class Container, class TestPolicy >
|
template< range_return_value result_type, class Container, class TestPolicy >
|
||||||
struct test_range
|
struct test_range
|
||||||
{
|
{
|
||||||
void operator()(Container& cont, TestPolicy policy)
|
void operator()(Container& cont, TestPolicy policy)
|
||||||
{
|
{
|
||||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iterator_t;
|
typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>::type iterator_t;
|
||||||
typedef BOOST_DEDUCED_TYPENAME range_return<Container, result_type>::type range_return_t;
|
typedef BOOST_DEDUCED_TYPENAME range_return<Container, result_type>::type range_return_t;
|
||||||
typedef BOOST_DEDUCED_TYPENAME TestPolicy::template test_range<result_type> test_range_t;
|
typedef BOOST_DEDUCED_TYPENAME TestPolicy::template test_range<result_type> test_range_t;
|
||||||
|
|
||||||
Container reference(cont);
|
Container reference(cont);
|
||||||
Container test_cont(cont);
|
Container test_cont(cont);
|
||||||
|
|
||||||
range_return_t range_result = test_range_t()(policy, test_cont);
|
range_return_t range_result = test_range_t()(policy, test_cont);
|
||||||
iterator_t reference_it = policy.reference(reference);
|
iterator_t reference_it = policy.reference(reference);
|
||||||
|
|
||||||
check_results<result_type>::check(test_cont, reference,
|
check_results<result_type>::check(test_cont, reference,
|
||||||
range_result, reference_it);
|
range_result, reference_it);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user