Updated Boost libraries to version 1.49, and recompiled them with NDK r8d

This commit is contained in:
pelya
2013-01-05 20:34:39 +02:00
parent 1c1e8f84ad
commit ebebac16b6
3885 changed files with 464519 additions and 52852 deletions

View File

@@ -116,7 +116,7 @@ namespace boost
};
template< class P, class R, bool default_pass >
struct adjacent_filter_range
struct adjacent_filtered_range
: iterator_range< skip_iterator<
BOOST_DEDUCED_TYPENAME range_iterator<R>::type,
P,
@@ -138,15 +138,11 @@ namespace boost
typedef BOOST_DEDUCED_TYPENAME range_iterator<R>::type raw_iterator;
public:
adjacent_filter_range( const P& p, R& r )
adjacent_filtered_range( const P& p, R& r )
: base_range(skip_iter(boost::begin(r), boost::end(r), p),
skip_iter(boost::end(r), boost::end(r), p))
{
}
private:
P m_pred;
R* m_range;
};
template< class T >
@@ -164,37 +160,37 @@ namespace boost
};
template< class ForwardRng, class BinPredicate >
inline adjacent_filter_range<BinPredicate, ForwardRng, true>
inline adjacent_filtered_range<BinPredicate, ForwardRng, true>
operator|( ForwardRng& r,
const adjacent_holder<BinPredicate>& f )
{
return adjacent_filter_range<BinPredicate, ForwardRng, true>( f.val, r );
return adjacent_filtered_range<BinPredicate, ForwardRng, true>( f.val, r );
}
template< class ForwardRng, class BinPredicate >
inline adjacent_filter_range<BinPredicate, const ForwardRng, true>
inline adjacent_filtered_range<BinPredicate, const ForwardRng, true>
operator|( const ForwardRng& r,
const adjacent_holder<BinPredicate>& f )
{
return adjacent_filter_range<BinPredicate,
const ForwardRng, true>( f.val, r );
return adjacent_filtered_range<BinPredicate,
const ForwardRng, true>( f.val, r );
}
template< class ForwardRng, class BinPredicate >
inline adjacent_filter_range<BinPredicate, ForwardRng, false>
inline adjacent_filtered_range<BinPredicate, ForwardRng, false>
operator|( ForwardRng& r,
const adjacent_excl_holder<BinPredicate>& f )
{
return adjacent_filter_range<BinPredicate, ForwardRng, false>( f.val, r );
return adjacent_filtered_range<BinPredicate, ForwardRng, false>( f.val, r );
}
template< class ForwardRng, class BinPredicate >
inline adjacent_filter_range<BinPredicate, ForwardRng, false>
inline adjacent_filtered_range<BinPredicate, ForwardRng, false>
operator|( const ForwardRng& r,
const adjacent_excl_holder<BinPredicate>& f )
{
return adjacent_filter_range<BinPredicate,
const ForwardRng, false>( f.val, r );
return adjacent_filtered_range<BinPredicate,
const ForwardRng, false>( f.val, r );
}
} // 'range_detail'
@@ -202,7 +198,7 @@ namespace boost
// Bring adjacent_filter_range into the boost namespace so that users of
// this library may specify the return type of the '|' operator and
// adjacent_filter()
using range_detail::adjacent_filter_range;
using range_detail::adjacent_filtered_range;
namespace adaptors
{
@@ -218,17 +214,17 @@ namespace boost
}
template<class ForwardRng, class BinPredicate>
inline adjacent_filter_range<BinPredicate, ForwardRng, true>
inline adjacent_filtered_range<BinPredicate, ForwardRng, true>
adjacent_filter(ForwardRng& rng, BinPredicate filter_pred)
{
return adjacent_filter_range<BinPredicate, ForwardRng, true>(filter_pred, rng);
return adjacent_filtered_range<BinPredicate, ForwardRng, true>(filter_pred, rng);
}
template<class ForwardRng, class BinPredicate>
inline adjacent_filter_range<BinPredicate, const ForwardRng, true>
inline adjacent_filtered_range<BinPredicate, const ForwardRng, true>
adjacent_filter(const ForwardRng& rng, BinPredicate filter_pred)
{
return adjacent_filter_range<BinPredicate, const ForwardRng, true>(filter_pred, rng);
return adjacent_filtered_range<BinPredicate, const ForwardRng, true>(filter_pred, rng);
}
} // 'adaptors'

View File

View File

View File

@@ -1,3 +1,13 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DEFINE_ADAPTOR_HPP_INCLUDED
#define BOOST_RANGE_DEFINE_ADAPTOR_HPP_INCLUDED
@@ -34,24 +44,6 @@
return range_adaptor <const Range>(rng); \
}
#define BOOST_DEFINE_RANGE_ADAPTOR_1( adaptor_name, range_adaptor, adaptor_class ) \
template<typename Range> range_adaptor <Range> \
operator|(Range& rng, const adaptor_name & args) \
{ \
return range_adaptor <Range>(rng, args.arg1); \
} \
template<typename Range> range_adaptor <const Range> \
operator|(const Range& rng, const adaptor_name & args) \
{ \
return range_adaptor <Range>(rng, args.arg1); \
} \
template<typename Range, typename Arg1> \
range_adaptor<Range> \
make_##adaptor_name(Range& rng, Arg1 arg1) \
{ \
return range_adaptor<Range>(rng, arg1); \
}
#define BOOST_DEFINE_RANGE_ADAPTOR_1( adaptor_name, range_adaptor, arg1_type ) \
struct adaptor_name \
{ \

View File

@@ -20,7 +20,7 @@ namespace boost
namespace range_detail
{
template< class P, class R >
struct filter_range :
struct filtered_range :
boost::iterator_range<
boost::filter_iterator< P,
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
@@ -34,7 +34,7 @@ namespace boost
>
> base;
public:
filter_range( P p, R& r )
filtered_range( P p, R& r )
: base( make_filter_iterator( p, boost::begin(r), boost::end(r) ),
make_filter_iterator( p, boost::end(r), boost::end(r) ) )
{ }
@@ -48,19 +48,19 @@ namespace boost
};
template< class InputRng, class Predicate >
inline filter_range<Predicate, InputRng>
inline filtered_range<Predicate, InputRng>
operator|( InputRng& r,
const filter_holder<Predicate>& f )
{
return filter_range<Predicate, InputRng>( f.val, r );
return filtered_range<Predicate, InputRng>( f.val, r );
}
template< class InputRng, class Predicate >
inline filter_range<Predicate, const InputRng>
inline filtered_range<Predicate, const InputRng>
operator|( const InputRng& r,
const filter_holder<Predicate>& f )
{
return filter_range<Predicate, const InputRng>( f.val, r );
return filtered_range<Predicate, const InputRng>( f.val, r );
}
} // 'range_detail'
@@ -70,7 +70,7 @@ namespace boost
// 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;
using range_detail::filtered_range;
namespace adaptors
{
@@ -82,17 +82,17 @@ namespace boost
}
template<class InputRange, class Predicate>
inline filter_range<Predicate, InputRange>
inline filtered_range<Predicate, InputRange>
filter(InputRange& rng, Predicate filter_pred)
{
return range_detail::filter_range<Predicate, InputRange>( filter_pred, rng );
return range_detail::filtered_range<Predicate, InputRange>( filter_pred, rng );
}
template<class InputRange, class Predicate>
inline filter_range<Predicate, const InputRange>
inline filtered_range<Predicate, const InputRange>
filter(const InputRange& rng, Predicate filter_pred)
{
return range_detail::filter_range<Predicate, const InputRange>( filter_pred, rng );
return range_detail::filtered_range<Predicate, const InputRange>( filter_pred, rng );
}
} // 'adaptors'

View File

View File

@@ -19,7 +19,7 @@ namespace boost
namespace range_detail
{
template< class R >
struct indirect_range :
struct indirected_range :
public boost::iterator_range<
boost::indirect_iterator<
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
@@ -35,7 +35,7 @@ namespace boost
base;
public:
explicit indirect_range( R& r )
explicit indirected_range( R& r )
: base( r )
{ }
};
@@ -43,22 +43,22 @@ namespace boost
struct indirect_forwarder {};
template< class InputRng >
inline indirect_range<InputRng>
inline indirected_range<InputRng>
operator|( InputRng& r, indirect_forwarder )
{
return indirect_range<InputRng>( r );
return indirected_range<InputRng>( r );
}
template< class InputRng >
inline indirect_range<const InputRng>
inline indirected_range<const InputRng>
operator|( const InputRng& r, indirect_forwarder )
{
return indirect_range<const InputRng>( r );
return indirected_range<const InputRng>( r );
}
} // 'range_detail'
using range_detail::indirect_range;
using range_detail::indirected_range;
namespace adaptors
{
@@ -69,17 +69,17 @@ namespace boost
}
template<class InputRange>
inline indirect_range<InputRange>
inline indirected_range<InputRange>
indirect(InputRange& rng)
{
return indirect_range<InputRange>(rng);
return indirected_range<InputRange>(rng);
}
template<class InputRange>
inline indirect_range<const InputRange>
inline indirected_range<const InputRange>
indirect(const InputRange& rng)
{
return indirect_range<const InputRange>(rng);
return indirected_range<const InputRange>(rng);
}
} // 'adaptors'

39
project/jni/boost/include/boost/range/adaptor/map.hpp Executable file → Normal file
View File

@@ -14,6 +14,7 @@
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/reference.hpp>
namespace boost
{
@@ -25,11 +26,10 @@ namespace boost
template< class Map >
struct select_first
{
typedef BOOST_DEDUCED_TYPENAME range_value<Map>::type pair_t;
typedef const BOOST_DEDUCED_TYPENAME pair_t::first_type&
result_type;
typedef BOOST_DEDUCED_TYPENAME range_reference<const Map>::type argument_type;
typedef const BOOST_DEDUCED_TYPENAME range_value<const Map>::type::first_type& result_type;
result_type operator()( const pair_t& r ) const
result_type operator()( argument_type r ) const
{
return r.first;
}
@@ -38,10 +38,10 @@ namespace boost
template< class Map >
struct select_second_mutable
{
typedef BOOST_DEDUCED_TYPENAME range_value<Map>::type pair_t;
typedef BOOST_DEDUCED_TYPENAME pair_t::second_type& result_type;
typedef BOOST_DEDUCED_TYPENAME range_reference<Map>::type argument_type;
typedef BOOST_DEDUCED_TYPENAME range_value<Map>::type::second_type& result_type;
result_type operator()( pair_t& r ) const
result_type operator()( argument_type r ) const
{
return r.second;
}
@@ -50,11 +50,10 @@ namespace boost
template< class Map >
struct select_second_const
{
typedef BOOST_DEDUCED_TYPENAME range_value<Map>::type pair_t;
typedef const BOOST_DEDUCED_TYPENAME pair_t::second_type&
result_type;
typedef BOOST_DEDUCED_TYPENAME range_reference<const Map>::type argument_type;
typedef const BOOST_DEDUCED_TYPENAME range_value<const Map>::type::second_type& result_type;
result_type operator()( const pair_t& r ) const
result_type operator()( argument_type r ) const
{
return r.second;
}
@@ -62,11 +61,11 @@ namespace boost
template<class StdPairRng>
class select_first_range
: public transform_range<
: public transformed_range<
select_first<StdPairRng>,
const StdPairRng>
{
typedef transform_range<select_first<StdPairRng>, const StdPairRng> base;
typedef transformed_range<select_first<StdPairRng>, const StdPairRng> base;
public:
typedef select_first<StdPairRng> transform_fn_type;
typedef const StdPairRng source_range_type;
@@ -81,11 +80,11 @@ namespace boost
template<class StdPairRng>
class select_second_mutable_range
: public transform_range<
: public transformed_range<
select_second_mutable<StdPairRng>,
StdPairRng>
{
typedef transform_range<select_second_mutable<StdPairRng>, StdPairRng> base;
typedef transformed_range<select_second_mutable<StdPairRng>, StdPairRng> base;
public:
typedef select_second_mutable<StdPairRng> transform_fn_type;
typedef StdPairRng source_range_type;
@@ -100,11 +99,11 @@ namespace boost
template<class StdPairRng>
class select_second_const_range
: public transform_range<
: public transformed_range<
select_second_const<StdPairRng>,
const StdPairRng>
{
typedef transform_range<select_second_const<StdPairRng>, const StdPairRng> base;
typedef transformed_range<select_second_const<StdPairRng>, const StdPairRng> base;
public:
typedef select_second_const<StdPairRng> transform_fn_type;
typedef const StdPairRng source_range_type;
@@ -122,7 +121,7 @@ namespace boost
operator|( const StdPairRng& r, map_keys_forwarder )
{
return operator|( r,
boost::adaptors::transformed( select_first<StdPairRng>() ) );
boost::adaptors::transformed( select_first<StdPairRng>() ) );
}
template< class StdPairRng >
@@ -130,7 +129,7 @@ namespace boost
operator|( StdPairRng& r, map_values_forwarder )
{
return operator|( r,
boost::adaptors::transformed( select_second_mutable<StdPairRng>() ) );
boost::adaptors::transformed( select_second_mutable<StdPairRng>() ) );
}
template< class StdPairRng >
@@ -138,7 +137,7 @@ namespace boost
operator|( const StdPairRng& r, map_values_forwarder )
{
return operator|( r,
boost::adaptors::transformed( select_second_const<StdPairRng>() ) );
boost::adaptors::transformed( select_second_const<StdPairRng>() ) );
}
} // 'range_detail'

View File

@@ -47,7 +47,7 @@ namespace boost
};
template< class Pred, class R >
class replace_if_range :
class replaced_if_range :
public boost::iterator_range<
boost::transform_iterator<
replace_value_if< Pred, BOOST_DEDUCED_TYPENAME range_value<R>::type >,
@@ -64,7 +64,7 @@ namespace boost
public:
typedef BOOST_DEDUCED_TYPENAME range_value<R>::type value_type;
replace_if_range( R& r, const Pred& pred, value_type to )
replaced_if_range( R& r, const Pred& pred, value_type to )
: base_t( make_transform_iterator( boost::begin(r), Fn(pred, to) ),
make_transform_iterator( boost::end(r), Fn(pred, to) ) )
{ }
@@ -87,23 +87,23 @@ namespace boost
};
template< class Pred, class InputRng >
inline replace_if_range<Pred, InputRng>
inline replaced_if_range<Pred, InputRng>
operator|( InputRng& r,
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 replaced_if_range<Pred, InputRng>(r, f.pred(), f.to());
}
template< class Pred, class InputRng >
inline replace_if_range<Pred, const InputRng>
inline replaced_if_range<Pred, const InputRng>
operator|( const InputRng& r,
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 replaced_if_range<Pred, const InputRng>(r, f.pred(), f.to());
}
} // 'range_detail'
using range_detail::replace_if_range;
using range_detail::replaced_if_range;
namespace adaptors
{
@@ -115,19 +115,19 @@ namespace boost
}
template<class Pred, class InputRange>
inline replace_if_range<Pred, InputRange>
inline replaced_if_range<Pred, InputRange>
replace_if(InputRange& rng, Pred pred,
BOOST_DEDUCED_TYPENAME range_value<InputRange>::type to)
{
return range_detail::replace_if_range<Pred, InputRange>(rng, pred, to);
return range_detail::replaced_if_range<Pred, InputRange>(rng, pred, to);
}
template<class Pred, class InputRange>
inline replace_if_range<Pred, const InputRange>
inline replaced_if_range<Pred, const InputRange>
replace_if(const InputRange& rng, Pred pred,
BOOST_DEDUCED_TYPENAME range_value<const InputRange>::type to)
{
return range_detail::replace_if_range<Pred, const InputRange>(rng, pred, to);
return range_detail::replaced_if_range<Pred, const InputRange>(rng, pred, to);
}
} // 'adaptors'

View File

@@ -19,7 +19,7 @@ namespace boost
namespace range_detail
{
template< class R >
struct reverse_range :
struct reversed_range :
public boost::iterator_range<
boost::reverse_iterator<
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
@@ -37,7 +37,7 @@ namespace boost
public:
typedef boost::reverse_iterator<BOOST_DEDUCED_TYPENAME range_iterator<R>::type> iterator;
reverse_range( R& r )
explicit reversed_range( R& r )
: base( iterator(boost::end(r)), iterator(boost::begin(r)) )
{ }
};
@@ -45,22 +45,22 @@ namespace boost
struct reverse_forwarder {};
template< class BidirectionalRng >
inline reverse_range<BidirectionalRng>
inline reversed_range<BidirectionalRng>
operator|( BidirectionalRng& r, reverse_forwarder )
{
return reverse_range<BidirectionalRng>( r );
return reversed_range<BidirectionalRng>( r );
}
template< class BidirectionalRng >
inline reverse_range<const BidirectionalRng>
inline reversed_range<const BidirectionalRng>
operator|( const BidirectionalRng& r, reverse_forwarder )
{
return reverse_range<const BidirectionalRng>( r );
return reversed_range<const BidirectionalRng>( r );
}
} // 'range_detail'
using range_detail::reverse_range;
using range_detail::reversed_range;
namespace adaptors
{
@@ -71,17 +71,17 @@ namespace boost
}
template<class BidirectionalRange>
inline reverse_range<BidirectionalRange>
inline reversed_range<BidirectionalRange>
reverse(BidirectionalRange& rng)
{
return reverse_range<BidirectionalRange>(rng);
return reversed_range<BidirectionalRange>(rng);
}
template<class BidirectionalRange>
inline reverse_range<const BidirectionalRange>
inline reversed_range<const BidirectionalRange>
reverse(const BidirectionalRange& rng)
{
return reverse_range<const BidirectionalRange>(rng);
return reversed_range<const BidirectionalRange>(rng);
}
} // 'adaptors'

View File

@@ -27,55 +27,56 @@ namespace boost
std::size_t u;
};
template< class RandomAccessRange >
class sliced_range : public boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
{
typedef boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type > base_t;
public:
template<typename Rng, typename T, typename U>
sliced_range(Rng& rng, T t, U u)
: base_t(boost::make_iterator_range(rng, t, u - boost::size(rng)))
{
}
};
template< class RandomAccessRange >
class sliced_range : public boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type >
{
typedef boost::iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<RandomAccessRange>::type > base_t;
public:
template<typename Rng, typename T, typename U>
sliced_range(Rng& rng, T t, U u)
: base_t(boost::make_iterator_range(rng, t, u - boost::size(rng)))
{
}
};
template< class RandomAccessRange >
inline sliced_range<RandomAccessRange>
slice( RandomAccessRange& rng, std::size_t t, std::size_t u )
{
BOOST_ASSERT( t <= u && "error in slice indices" );
template< class RandomAccessRange >
inline sliced_range<RandomAccessRange>
slice( RandomAccessRange& rng, std::size_t t, std::size_t u )
{
BOOST_ASSERT( t <= u && "error in slice indices" );
BOOST_ASSERT( static_cast<std::size_t>(boost::size(rng)) >= u &&
"second slice index out of bounds" );
"second slice index out of bounds" );
return sliced_range<RandomAccessRange>(rng, t, u);
}
return sliced_range<RandomAccessRange>(rng, t, u);
}
template< class RandomAccessRange >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type >
slice( const RandomAccessRange& rng, std::size_t t, std::size_t u )
{
BOOST_ASSERT( t <= u && "error in slice indices" );
BOOST_ASSERT( static_cast<std::size_t>(boost::size(rng)) >= u &&
"second slice index out of bounds" );
template< class RandomAccessRange >
inline iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<const RandomAccessRange>::type >
slice( const RandomAccessRange& rng, std::size_t t, std::size_t u )
{
BOOST_ASSERT( t <= u && "error in slice indices" );
BOOST_ASSERT( static_cast<std::size_t>(boost::size(rng)) >= u &&
"second slice index out of bounds" );
return sliced_range<const RandomAccessRange>(rng, t, u);
}
}
template< class RandomAccessRange >
inline sliced_range<RandomAccessRange>
operator|( RandomAccessRange& r, const sliced& f )
{
return sliced_range<RandomAccessRange>( r, f.t, f.u );
}
template< class RandomAccessRange >
inline sliced_range<RandomAccessRange>
operator|( RandomAccessRange& r, const sliced& f )
{
return sliced_range<RandomAccessRange>( r, f.t, f.u );
}
template< class RandomAccessRange >
inline sliced_range<const RandomAccessRange>
operator|( const RandomAccessRange& r, const sliced& f )
{
return sliced_range<const RandomAccessRange>( r, f.t, f.u );
}
template< class RandomAccessRange >
inline sliced_range<const RandomAccessRange>
operator|( const RandomAccessRange& r, const sliced& f )
{
return sliced_range<const RandomAccessRange>( r, f.t, f.u );
}
} // namespace adaptors
using adaptors::sliced_range;
} // namespace boost
#endif

317
project/jni/boost/include/boost/range/adaptor/strided.hpp Executable file → Normal file
View File

@@ -20,78 +20,279 @@ namespace boost
{
namespace range_detail
{
template<typename BaseIterator>
// strided_iterator for wrapping a forward traversal iterator
template<class BaseIterator, class Category>
class strided_iterator
: public iterator_adaptor<
strided_iterator<BaseIterator>,
BaseIterator>
strided_iterator<BaseIterator, Category>
, BaseIterator
, use_default
, boost::forward_traversal_tag
>
{
friend class iterator_core_access;
friend class ::boost::iterator_core_access;
typedef iterator_adaptor<
strided_iterator<BaseIterator, Category>
, BaseIterator
, use_default
, boost::forward_traversal_tag
> super_t;
typedef iterator_adaptor<strided_iterator<BaseIterator>, BaseIterator> super_t;
public:
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
strided_iterator() : m_stride() { }
strided_iterator(const strided_iterator& other)
: super_t(other), m_stride(other.m_stride) { }
explicit strided_iterator(BaseIterator base_it, difference_type stride)
: super_t(base_it), m_stride(stride) { }
strided_iterator&
operator=(const strided_iterator& other)
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
typedef BaseIterator base_iterator;
strided_iterator()
: m_last()
, m_stride()
{
super_t::operator=(other);
// Is the interoperation of the stride safe?
m_stride = other.m_stride;
return *this;
}
void increment() { 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); }
difference_type
distance_to(const strided_iterator& other) const
{
return std::distance(this->base_reference(), other.base_reference()) / m_stride;
}
// Using the compiler generated copy constructor and
// and assignment operator
strided_iterator(base_iterator first, base_iterator it, base_iterator last, difference_type stride)
: super_t(it)
, m_last(last)
, m_stride(stride)
{
}
template<class OtherIterator>
strided_iterator(const strided_iterator<OtherIterator, Category>& other,
BOOST_DEDUCED_TYPENAME enable_if_convertible<OtherIterator, base_iterator>::type* = 0)
: super_t(other)
, m_last(other.base_end())
, m_stride(other.get_stride())
{
}
base_iterator base_end() const { return m_last; }
difference_type get_stride() const { return m_stride; }
private:
void increment()
{
base_iterator& it = this->base_reference();
for (difference_type i = 0; (it != m_last) && (i < m_stride); ++i)
++it;
}
base_iterator m_last;
difference_type m_stride;
};
template<class BaseIterator> inline
strided_iterator<BaseIterator>
make_strided_iterator(
const BaseIterator& first,
BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type stride)
// strided_iterator for wrapping a bidirectional iterator
template<class BaseIterator>
class strided_iterator<BaseIterator, bidirectional_traversal_tag>
: public iterator_adaptor<
strided_iterator<BaseIterator, bidirectional_traversal_tag>
, BaseIterator
, use_default
, bidirectional_traversal_tag
>
{
return strided_iterator<BaseIterator>(first, stride);
friend class ::boost::iterator_core_access;
typedef iterator_adaptor<
strided_iterator<BaseIterator, bidirectional_traversal_tag>
, BaseIterator
, use_default
, bidirectional_traversal_tag
> super_t;
public:
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
typedef BaseIterator base_iterator;
strided_iterator()
: m_first()
, m_last()
, m_stride()
{
}
strided_iterator(base_iterator first, base_iterator it, base_iterator last, difference_type stride)
: super_t(it)
, m_first(first)
, m_last(last)
, m_stride(stride)
{
}
template<class OtherIterator>
strided_iterator(const strided_iterator<OtherIterator, bidirectional_traversal_tag>& other,
BOOST_DEDUCED_TYPENAME enable_if_convertible<OtherIterator, base_iterator>::type* = 0)
: super_t(other.base())
, m_first(other.base_begin())
, m_last(other.base_end())
, m_stride(other.get_stride())
{
}
base_iterator base_begin() const { return m_first; }
base_iterator base_end() const { return m_last; }
difference_type get_stride() const { return m_stride; }
private:
void increment()
{
base_iterator& it = this->base_reference();
for (difference_type i = 0; (it != m_last) && (i < m_stride); ++i)
++it;
}
void decrement()
{
base_iterator& it = this->base_reference();
for (difference_type i = 0; (it != m_first) && (i < m_stride); ++i)
--it;
}
base_iterator m_first;
base_iterator m_last;
difference_type m_stride;
};
// strided_iterator implementation for wrapping a random access iterator
template<class BaseIterator>
class strided_iterator<BaseIterator, random_access_traversal_tag>
: public iterator_adaptor<
strided_iterator<BaseIterator, random_access_traversal_tag>
, BaseIterator
, use_default
, random_access_traversal_tag
>
{
friend class ::boost::iterator_core_access;
typedef iterator_adaptor<
strided_iterator<BaseIterator, random_access_traversal_tag>
, BaseIterator
, use_default
, random_access_traversal_tag
> super_t;
public:
typedef BOOST_DEDUCED_TYPENAME super_t::difference_type difference_type;
typedef BaseIterator base_iterator;
strided_iterator()
: m_first()
, m_last()
, m_index(0)
, m_stride()
{
}
strided_iterator(BaseIterator first, BaseIterator it, BaseIterator last, difference_type stride)
: super_t(it)
, m_first(first)
, m_last(last)
, m_index(stride ? (it - first) / stride : 0)
, m_stride(stride)
{
}
template<class OtherIterator>
strided_iterator(const strided_iterator<OtherIterator, random_access_traversal_tag>& other,
BOOST_DEDUCED_TYPENAME enable_if_convertible<OtherIterator, BaseIterator>::type* = 0)
: super_t(other.base())
, m_first(other.base_begin())
, m_last(other.base_end())
, m_index(other.get_index())
, m_stride(other.get_stride())
{
}
base_iterator base_begin() const { return m_first; }
base_iterator base_end() const { return m_last; }
difference_type get_stride() const { return m_stride; }
difference_type get_index() const { return m_index; }
private:
void increment()
{
m_index += m_stride;
if (m_index < (m_last - m_first))
this->base_reference() = m_first + m_index;
else
this->base_reference() = m_last;
}
void decrement()
{
m_index -= m_stride;
if (m_index >= 0)
this->base_reference() = m_first + m_index;
else
this->base_reference() = m_first;
}
void advance(difference_type offset)
{
offset *= m_stride;
m_index += offset;
if (m_index < 0)
this->base_reference() = m_first;
else if (m_index > (m_last - m_first))
this->base_reference() = m_last;
else
this->base_reference() = m_first + m_index;
}
template<class OtherIterator>
difference_type distance_to(const strided_iterator<OtherIterator, random_access_traversal_tag>& other,
BOOST_DEDUCED_TYPENAME enable_if_convertible<OtherIterator, BaseIterator>::type* = 0) const
{
if (other.base() >= this->base())
return (other.base() - this->base() + (m_stride - 1)) / m_stride;
return (other.base() - this->base() - (m_stride - 1)) / m_stride;
}
bool equal(const strided_iterator& other) const
{
return this->base() == other.base();
}
private:
base_iterator m_first;
base_iterator m_last;
difference_type m_index;
difference_type m_stride;
};
template<class BaseIterator, class Difference> inline
strided_iterator<BaseIterator, BOOST_DEDUCED_TYPENAME iterator_traversal<BaseIterator>::type>
make_strided_iterator(BaseIterator first, BaseIterator it,
BaseIterator last, Difference stride)
{
BOOST_ASSERT( stride >= 0 );
typedef BOOST_DEDUCED_TYPENAME iterator_traversal<BaseIterator>::type traversal_tag;
return strided_iterator<BaseIterator, traversal_tag>(first, it, last, stride);
}
template< class Rng >
template< class Rng
, class Category = BOOST_DEDUCED_TYPENAME iterator_traversal<
BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type
>::type
>
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,
Category
>
>
{
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,
Category
> iter_type;
typedef iterator_range<iter_type> super_t;
public:
template< typename Difference >
template<class Difference>
strided_range(Difference stride, Rng& rng)
: super_t(make_strided_iterator(boost::begin(rng), stride),
make_strided_iterator(boost::end(rng), stride))
: super_t(make_strided_iterator(boost::begin(rng), boost::begin(rng), boost::end(rng), stride),
make_strided_iterator(boost::begin(rng), boost::end(rng), boost::end(rng), stride))
{
BOOST_ASSERT( stride >= 0 );
}
};
@@ -99,7 +300,7 @@ namespace boost
class strided_holder : public holder<Difference>
{
public:
strided_holder(Difference value) : holder<Difference>(value) {}
explicit strided_holder(Difference value) : holder<Difference>(value) {}
};
template<class Rng, class Difference>
@@ -117,32 +318,32 @@ namespace boost
}
} // namespace range_detail
using range_detail::strided_range;
namespace adaptors
{
namespace
{
const 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'
} // namespace 'boost'

View File

@@ -20,7 +20,7 @@ namespace boost
{
template< class R >
struct token_range :
struct tokenized_range :
public boost::iterator_range<
boost::regex_token_iterator<
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
@@ -42,7 +42,7 @@ namespace boost
public:
template< class Regex, class Submatch, class Flag >
token_range( R& r, const Regex& re, const Submatch& sub, Flag f )
tokenized_range( R& r, const Regex& re, const Submatch& sub, Flag f )
: base( regex_iter( boost::begin(r), boost::end(r),
regex_type(re), sub, f ),
regex_iter() )
@@ -90,24 +90,24 @@ namespace boost
};
template< class BidirectionalRng, class R, class S, class F >
inline token_range<BidirectionalRng>
inline tokenized_range<BidirectionalRng>
operator|( BidirectionalRng& r,
const regex_holder<R,S,F>& f )
{
return token_range<BidirectionalRng>( r, f.re, f.sub, f.f );
return tokenized_range<BidirectionalRng>( r, f.re, f.sub, f.f );
}
template< class BidirectionalRng, class R, class S, class F >
inline token_range<const BidirectionalRng>
inline tokenized_range<const BidirectionalRng>
operator|( const BidirectionalRng& r,
const regex_holder<R,S,F>& f )
{
return token_range<const BidirectionalRng>( r, f.re, f.sub, f.f );
return tokenized_range<const BidirectionalRng>( r, f.re, f.sub, f.f );
}
} // 'range_detail'
using range_detail::token_range;
using range_detail::tokenized_range;
namespace adaptors
{
@@ -118,17 +118,17 @@ namespace boost
}
template<class BidirectionalRange, class Regex, class Submatch, class Flag>
inline token_range<BidirectionalRange>
inline tokenized_range<BidirectionalRange>
tokenize(BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f)
{
return token_range<BidirectionalRange>(rng, reg, sub, f);
return tokenized_range<BidirectionalRange>(rng, reg, sub, f);
}
template<class BidirectionalRange, class Regex, class Submatch, class Flag>
inline token_range<const BidirectionalRange>
inline tokenized_range<const BidirectionalRange>
tokenize(const BidirectionalRange& rng, const Regex& reg, const Submatch& sub, Flag f)
{
return token_range<const BidirectionalRange>(rng, reg, sub, f);
return tokenized_range<const BidirectionalRange>(rng, reg, sub, f);
}
} // 'adaptors'

View File

@@ -14,6 +14,7 @@
#include <boost/range/adaptor/argument_fwd.hpp>
#include <boost/range/iterator_range.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/utility/result_of.hpp>
namespace boost
{
@@ -21,17 +22,17 @@ namespace boost
{
template< class F, class R >
struct transform_range :
public boost::iterator_range<
struct transformed_range :
public boost::iterator_range<
boost::transform_iterator< F,
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
>
>
{
private:
typedef boost::iterator_range<
typedef boost::iterator_range<
boost::transform_iterator< F,
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
BOOST_DEDUCED_TYPENAME range_iterator<R>::type
>
>
base;
@@ -39,11 +40,11 @@ namespace boost
public:
typedef F transform_fn_type;
typedef R source_range_type;
transform_range( F f, R& r )
: base( make_transform_iterator( boost::begin(r), f ),
make_transform_iterator( boost::end(r), f ) )
transformed_range( F f, R& r )
: base( boost::make_transform_iterator( boost::begin(r), f ),
boost::make_transform_iterator( boost::end(r), f ) )
{ }
};
@@ -53,51 +54,51 @@ namespace boost
transform_holder( T r ) : holder<T>(r)
{ }
};
template< class InputRng, class UnaryFunction >
inline transform_range<UnaryFunction,InputRng>
operator|( InputRng& r,
inline transformed_range<UnaryFunction,InputRng>
operator|( InputRng& r,
const transform_holder<UnaryFunction>& f )
{
return transform_range<UnaryFunction,InputRng>( f.val, r );
return transformed_range<UnaryFunction,InputRng>( f.val, r );
}
template< class InputRng, class UnaryFunction >
inline transform_range<UnaryFunction, const InputRng>
operator|( const InputRng& r,
inline transformed_range<UnaryFunction, const InputRng>
operator|( const InputRng& r,
const transform_holder<UnaryFunction>& f )
{
return transform_range<UnaryFunction, const InputRng>( f.val, r );
return transformed_range<UnaryFunction, const InputRng>( f.val, r );
}
} // 'range_detail'
using range_detail::transform_range;
using range_detail::transformed_range;
namespace adaptors
{
{
namespace
{
const range_detail::forwarder<range_detail::transform_holder>
transformed =
const range_detail::forwarder<range_detail::transform_holder>
transformed =
range_detail::forwarder<range_detail::transform_holder>();
}
template<class UnaryFunction, class InputRange>
inline transform_range<UnaryFunction, InputRange>
inline transformed_range<UnaryFunction, InputRange>
transform(InputRange& rng, UnaryFunction fn)
{
return transform_range<UnaryFunction, InputRange>(fn, rng);
return transformed_range<UnaryFunction, InputRange>(fn, rng);
}
template<class UnaryFunction, class InputRange>
inline transform_range<UnaryFunction, const InputRange>
inline transformed_range<UnaryFunction, const InputRange>
transform(const InputRange& rng, UnaryFunction fn)
{
return transform_range<UnaryFunction, const InputRange>(fn, rng);
return transformed_range<UnaryFunction, const InputRange>(fn, rng);
}
} // 'adaptors'
}
#endif

View File

@@ -0,0 +1,184 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_ADAPTOR_TYPE_ERASED_HPP_INCLUDED
#define BOOST_RANGE_ADAPTOR_TYPE_ERASED_HPP_INCLUDED
#include <boost/range/reference.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/range/any_range.hpp>
#include <boost/cast.hpp>
namespace boost
{
namespace adaptors
{
template<
class Value = use_default
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
, class Buffer = use_default
>
struct type_erased
{
};
template<
class SinglePassRange
, class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
typename any_range_type_generator<
SinglePassRange
, Value
, Traversal
, Reference
, Difference
, Buffer
>::type
operator|(SinglePassRange& rng,
type_erased<
Value
, Traversal
, Reference
, Difference
, Buffer
>)
{
typedef typename any_range_type_generator<
SinglePassRange
, Value
, Traversal
, Reference
, Difference
, Buffer
>::type range_type;
return range_type(boost::begin(rng), boost::end(rng));
}
template<
class SinglePassRange
, class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
typename any_range_type_generator<
const SinglePassRange
, Value
, Traversal
, Reference
, Difference
, Buffer
>::type
operator|(const SinglePassRange& rng,
type_erased<
Value
, Traversal
, Reference
, Difference
, Buffer
>)
{
typedef typename any_range_type_generator<
const SinglePassRange
, Value
, Traversal
, Reference
, Difference
, Buffer
>::type range_type;
return range_type(boost::begin(rng), boost::end(rng));
}
template<
class SinglePassRange
, class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
typename any_range_type_generator<
SinglePassRange
, Value
, Traversal
, Reference
, Difference
, Buffer
>::type
type_erase(SinglePassRange& rng
, type_erased<
Value
, Traversal
, Reference
, Difference
, Buffer
> = type_erased<>()
)
{
typedef typename any_range_type_generator<
SinglePassRange
, Value
, Traversal
, Reference
, Difference
, Buffer
>::type range_type;
return range_type(boost::begin(rng), boost::end(rng));
}
template<
class SinglePassRange
, class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
typename any_range_type_generator<
const SinglePassRange
, Value
, Traversal
, Reference
, Difference
, Buffer
>::type
type_erase(const SinglePassRange& rng
, type_erased<
Value
, Traversal
, Reference
, Difference
, Buffer
> = type_erased<>()
)
{
typedef typename any_range_type_generator<
const SinglePassRange
, Value
, Traversal
, Reference
, Difference
, Buffer
>::type range_type;
return range_type(boost::begin(rng), boost::end(rng));
}
}
} // namespace boost
#endif // include guard

View File

@@ -32,35 +32,35 @@ namespace boost
};
template<class ForwardRng>
class unique_range : public adjacent_filter_range<unique_not_equal_to, ForwardRng, true>
class uniqued_range : public adjacent_filtered_range<unique_not_equal_to, ForwardRng, true>
{
typedef adjacent_filter_range<unique_not_equal_to, ForwardRng, true> base;
typedef adjacent_filtered_range<unique_not_equal_to, ForwardRng, true> base;
public:
explicit unique_range(ForwardRng& rng)
explicit uniqued_range(ForwardRng& rng)
: base(unique_not_equal_to(), rng)
{
}
};
template< class ForwardRng >
inline unique_range<ForwardRng>
inline uniqued_range<ForwardRng>
operator|( ForwardRng& r,
unique_forwarder )
{
return unique_range<ForwardRng>(r);
return uniqued_range<ForwardRng>(r);
}
template< class ForwardRng >
inline unique_range<const ForwardRng>
inline uniqued_range<const ForwardRng>
operator|( const ForwardRng& r,
unique_forwarder )
{
return unique_range<const ForwardRng>(r);
return uniqued_range<const ForwardRng>(r);
}
} // 'range_detail'
using range_detail::unique_range;
using range_detail::uniqued_range;
namespace adaptors
{
@@ -71,17 +71,17 @@ namespace boost
}
template<class ForwardRange>
inline unique_range<ForwardRange>
inline uniqued_range<ForwardRange>
unique(ForwardRange& rng)
{
return unique_range<ForwardRange>(rng);
return uniqued_range<ForwardRange>(rng);
}
template<class ForwardRange>
inline unique_range<const ForwardRange>
inline uniqued_range<const ForwardRange>
unique(const ForwardRange& rng)
{
return unique_range<const ForwardRange>(rng);
return uniqued_range<const ForwardRange>(rng);
}
} // 'adaptors'

0
project/jni/boost/include/boost/range/adaptors.hpp Executable file → Normal file
View File

0
project/jni/boost/include/boost/range/algorithm.hpp Executable file → Normal file
View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@@ -13,13 +13,53 @@
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/ref.hpp>
#include <boost/utility.hpp>
#include <algorithm>
#if BOOST_WORKAROUND(BOOST_MSVC, == 1600)
#include <xutility>
#endif
namespace boost
{
namespace range
{
#if BOOST_WORKAROUND(BOOST_MSVC, == 1600)
namespace for_each_detail
{
template<typename Iterator, typename UnaryFunction>
inline UnaryFunction
for_each_impl(Iterator first, Iterator last, UnaryFunction fun,
typename enable_if<
is_reference_wrapper<UnaryFunction>,
void
>::type* = 0)
{
typedef typename std::_Get_unchecked_type<Iterator>::type
unchecked_iterator;
unchecked_iterator unchecked_last = std::_Unchecked(last);
for (unchecked_iterator unchecked_first = std::_Unchecked(first); first != last; ++first)
fun.get()(*unchecked_first);
return fun;
}
template<typename Iterator, typename UnaryFunction>
inline UnaryFunction
for_each_impl(Iterator first, Iterator last, UnaryFunction fn,
typename disable_if<
is_reference_wrapper<UnaryFunction>,
void
>::type* = 0)
{
return std::for_each<Iterator, UnaryFunction>(first, last, fn);
}
}
#endif
/// \brief template function for_each
///
/// range-based version of the for_each std algorithm
@@ -30,7 +70,18 @@ template< class SinglePassRange, class UnaryFunction >
inline UnaryFunction for_each(SinglePassRange & rng, UnaryFunction fun)
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
return std::for_each(boost::begin(rng),boost::end(rng),fun);
#if BOOST_WORKAROUND(BOOST_MSVC, == 1600)
return for_each_detail::for_each_impl<
typename range_iterator<SinglePassRange>::type,
UnaryFunction
>(boost::begin(rng), boost::end(rng), fun);
#else
return std::for_each<
BOOST_DEDUCED_TYPENAME range_iterator<SinglePassRange>::type,
UnaryFunction
>(boost::begin(rng),boost::end(rng),fun);
#endif
}
/// \overload
@@ -38,7 +89,18 @@ template< class SinglePassRange, class UnaryFunction >
inline UnaryFunction for_each(const SinglePassRange& rng, UnaryFunction fun)
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
return std::for_each(boost::begin(rng), boost::end(rng), fun);
#if BOOST_WORKAROUND(BOOST_MSVC, == 1600)
return for_each_detail::for_each_impl<
typename range_iterator<const SinglePassRange>::type,
UnaryFunction
>(boost::begin(rng), boost::end(rng), fun);
#else
return std::for_each<
BOOST_DEDUCED_TYPENAME range_iterator<const SinglePassRange>::type,
UnaryFunction
>(boost::begin(rng), boost::end(rng), fun);
#endif
}
} // namespace range

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@@ -15,6 +15,7 @@
#include <boost/range/concepts.hpp>
#include <boost/range/detail/range_return.hpp>
#include <boost/range/value_type.hpp>
#include <iterator>
#include <algorithm>
namespace boost
@@ -22,6 +23,218 @@ namespace boost
namespace range
{
namespace range_detail
{
// Rationale: search_n is implemented rather than delegate to
// the standard library implementation because some standard
// library implementations are broken eg. MSVC.
// search_n forward iterator version
template<typename ForwardIterator, typename Integer, typename Value>
inline ForwardIterator
search_n_impl(ForwardIterator first, ForwardIterator last, Integer count,
const Value& value, std::forward_iterator_tag)
{
first = std::find(first, last, value);
while (first != last)
{
typename std::iterator_traits<ForwardIterator>::difference_type n = count;
ForwardIterator i = first;
++i;
while (i != last && n != 1 && *i==value)
{
++i;
--n;
}
if (n == 1)
return first;
if (i == last)
return last;
first = std::find(++i, last, value);
}
return last;
}
// search_n random-access iterator version
template<typename RandomAccessIterator, typename Integer, typename Value>
inline RandomAccessIterator
search_n_impl(RandomAccessIterator first, RandomAccessIterator last,
Integer count, const Value& value,
std::random_access_iterator_tag)
{
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_t;
difference_t tail_size = last - first;
const difference_t pattern_size = count;
if (tail_size < pattern_size)
return last;
const difference_t skip_offset = pattern_size - 1;
RandomAccessIterator look_ahead = first + skip_offset;
tail_size -= pattern_size;
while (1)
{
// look_ahead here is pointing to the last element of the
// next possible match
while (!(*look_ahead == value)) // skip loop...
{
if (tail_size < pattern_size)
return last; // no match
look_ahead += pattern_size;
tail_size -= pattern_size;
}
difference_t remainder = skip_offset;
for (RandomAccessIterator back_track = look_ahead - 1;
*back_track == value; --back_track)
{
if (--remainder == 0)
{
return look_ahead - skip_offset; // matched
}
}
if (remainder > tail_size)
return last; // no match
look_ahead += remainder;
tail_size -= remainder;
}
return last;
}
// search_n for forward iterators using a binary predicate
// to determine a match
template<typename ForwardIterator, typename Integer, typename Value,
typename BinaryPredicate>
inline ForwardIterator
search_n_pred_impl(ForwardIterator first, ForwardIterator last,
Integer count, const Value& value,
BinaryPredicate pred, std::forward_iterator_tag)
{
typedef typename std::iterator_traits<ForwardIterator>::difference_type difference_t;
while (first != last && !static_cast<bool>(pred(*first, value)))
++first;
while (first != last)
{
difference_t n = count;
ForwardIterator i = first;
++i;
while (i != last && n != 1 && static_cast<bool>(pred(*i, value)))
{
++i;
--n;
}
if (n == 1)
return first;
if (i == last)
return last;
first = ++i;
while (first != last && !static_cast<bool>(pred(*first, value)))
++first;
}
return last;
}
// search_n for random-access iterators using a binary predicate
// to determine a match
template<typename RandomAccessIterator, typename Integer,
typename Value, typename BinaryPredicate>
inline RandomAccessIterator
search_n_pred_impl(RandomAccessIterator first, RandomAccessIterator last,
Integer count, const Value& value,
BinaryPredicate pred, std::random_access_iterator_tag)
{
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_t;
difference_t tail_size = last - first;
const difference_t pattern_size = count;
if (tail_size < pattern_size)
return last;
const difference_t skip_offset = pattern_size - 1;
RandomAccessIterator look_ahead = first + skip_offset;
tail_size -= pattern_size;
while (1)
{
// look_ahead points to the last element of the next
// possible match
while (!static_cast<bool>(pred(*look_ahead, value))) // skip loop
{
if (tail_size < pattern_size)
return last; // no match
look_ahead += pattern_size;
tail_size -= pattern_size;
}
difference_t remainder = skip_offset;
for (RandomAccessIterator back_track = look_ahead - 1;
pred(*back_track, value); --back_track)
{
if (--remainder == 0)
return look_ahead -= skip_offset; // success
}
if (remainder > tail_size)
{
return last; // no match
}
look_ahead += remainder;
tail_size -= remainder;
}
}
template<typename ForwardIterator, typename Integer, typename Value>
inline ForwardIterator
search_n_impl(ForwardIterator first, ForwardIterator last,
Integer count, const Value& value)
{
BOOST_RANGE_CONCEPT_ASSERT((ForwardIteratorConcept<ForwardIterator>));
BOOST_RANGE_CONCEPT_ASSERT((EqualityComparableConcept<Value>));
BOOST_RANGE_CONCEPT_ASSERT((EqualityComparableConcept<typename std::iterator_traits<ForwardIterator>::value_type>));
//BOOST_RANGE_CONCEPT_ASSERT((EqualityComparableConcept2<typename std::iterator_traits<ForwardIterator>::value_type, Value>));
typedef typename std::iterator_traits<ForwardIterator>::iterator_category cat_t;
if (count <= 0)
return first;
if (count == 1)
return std::find(first, last, value);
return range_detail::search_n_impl(first, last, count, value, cat_t());
}
template<typename ForwardIterator, typename Integer, typename Value,
typename BinaryPredicate>
inline ForwardIterator
search_n_pred_impl(ForwardIterator first, ForwardIterator last,
Integer count, const Value& value,
BinaryPredicate pred)
{
BOOST_RANGE_CONCEPT_ASSERT((ForwardIteratorConcept<ForwardIterator>));
BOOST_RANGE_CONCEPT_ASSERT((
BinaryPredicateConcept<
BinaryPredicate,
typename std::iterator_traits<ForwardIterator>::value_type,
Value>
));
typedef typename std::iterator_traits<ForwardIterator>::iterator_category cat_t;
if (count <= 0)
return first;
if (count == 1)
{
while (first != last && !static_cast<bool>(pred(*first, value)))
++first;
return first;
}
return range_detail::search_n_pred_impl(first, last, count,
value, pred, cat_t());
}
} // namespace range_detail
/// \brief template function search
///
/// range-based version of the search std algorithm
@@ -36,7 +249,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
search_n(ForwardRange& rng, Integer count, const Value& value)
{
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return std::search_n(boost::begin(rng),boost::end(rng), count, value);
return range_detail::search_n_impl(boost::begin(rng),boost::end(rng), count, value);
}
/// \overload
@@ -45,7 +258,7 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<const ForwardRange>::type
search_n(const ForwardRange& rng, Integer count, const Value& value)
{
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<const ForwardRange>));
return std::search_n(boost::begin(rng), boost::end(rng), count, value);
return range_detail::search_n_impl(boost::begin(rng), boost::end(rng), count, value);
}
/// \overload
@@ -58,7 +271,7 @@ search_n(ForwardRange& rng, Integer count, const Value& value,
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type, const Value&>));
return std::search_n(boost::begin(rng), boost::end(rng),
return range_detail::search_n_pred_impl(boost::begin(rng), boost::end(rng),
count, value, binary_pred);
}
@@ -72,7 +285,7 @@ search_n(const ForwardRange& rng, Integer count, const Value& value,
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<const ForwardRange>));
BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
BOOST_DEDUCED_TYPENAME range_value<const ForwardRange>::type, const Value&>));
return std::search_n(boost::begin(rng), boost::end(rng),
return range_detail::search_n_pred_impl(boost::begin(rng), boost::end(rng),
count, value, binary_pred);
}
@@ -86,7 +299,7 @@ search_n(ForwardRange& rng, Integer count, const Value& value)
{
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<ForwardRange>));
return range_return<ForwardRange,re>::
pack(std::search_n(boost::begin(rng),boost::end(rng),
pack(range_detail::search_n_impl(boost::begin(rng),boost::end(rng),
count, value),
rng);
}
@@ -99,7 +312,7 @@ search_n(const ForwardRange& rng, Integer count, const Value& value)
{
BOOST_RANGE_CONCEPT_ASSERT((ForwardRangeConcept<const ForwardRange>));
return range_return<const ForwardRange,re>::
pack(std::search_n(boost::begin(rng), boost::end(rng),
pack(range_detail::search_n_impl(boost::begin(rng), boost::end(rng),
count, value),
rng);
}
@@ -116,7 +329,8 @@ search_n(ForwardRange& rng, Integer count, const Value& value,
BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type,
const Value&>));
return range_return<ForwardRange,re>::
pack(std::search_n(boost::begin(rng), boost::end(rng),
pack(range_detail::search_n_pred_impl(boost::begin(rng),
boost::end(rng),
count, value, pred),
rng);
}
@@ -133,7 +347,8 @@ search_n(const ForwardRange& rng, Integer count, const Value& value,
BOOST_DEDUCED_TYPENAME range_value<const ForwardRange>::type,
const Value&>));
return range_return<const ForwardRange,re>::
pack(std::search_n(boost::begin(rng), boost::end(rng),
pack(range_detail::search_n_pred_impl(boost::begin(rng),
boost::end(rng),
count, value, pred),
rng);
}

View File

View File

View File

View File

View File

View File

@@ -84,7 +84,7 @@ namespace boost
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
return range_detail::transform_impl(
return boost::range_detail::transform_impl(
boost::begin(rng1), boost::end(rng1),
boost::begin(rng2), boost::end(rng2),
out, fun);

View File

View File

View File

View File

View File

View File

View File

View File

View File

@@ -1,3 +1,4 @@
// Copyright Bryce Lelbach 2010
// Copyright Neil Groves 2009. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -14,45 +15,26 @@
#include <boost/range/end.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/value_type.hpp>
#include <boost/detail/is_sorted.hpp>
#include <algorithm>
namespace boost
{
namespace range_detail
{
template<class ForwardIterator>
inline bool is_sorted(ForwardIterator first, ForwardIterator last)
{
for (ForwardIterator next = first; first != last && ++next != last; ++first)
if (*next < *first)
return false;
return true;
}
template<class ForwardIterator, class BinaryPredicate>
inline bool is_sorted(ForwardIterator first, ForwardIterator last, BinaryPredicate pred)
{
for (ForwardIterator next = first; first != last && ++next != last; ++first)
if (pred(*next, *first))
return false;
return true;
}
}
namespace range
{
/// \brief template function count
/// \brief template function is_sorted
///
/// range-based version of the count std algorithm
/// range-based version of the is_sorted std algorithm
///
/// \pre SinglePassRange is a model of the SinglePassRangeConcept
template<class SinglePassRange>
inline bool is_sorted(const SinglePassRange& rng)
{
BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
BOOST_RANGE_CONCEPT_ASSERT((LessThanComparableConcept<BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange>::type>));
return range_detail::is_sorted(boost::begin(rng), boost::end(rng));
BOOST_RANGE_CONCEPT_ASSERT((LessThanComparableConcept<BOOST_DEDUCED_TYPENAME
range_value<const SinglePassRange>::type>));
return ::boost::detail::is_sorted(boost::begin(rng), boost::end(rng));
}
/// \overload
@@ -60,12 +42,16 @@ template<class SinglePassRange, class BinaryPredicate>
inline bool is_sorted(const SinglePassRange& rng, BinaryPredicate pred)
{
BOOST_RANGE_CONCEPT_ASSERT((SinglePassRangeConcept<const SinglePassRange>));
BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate, BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange>::type, BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange>::type>));
return range_detail::is_sorted(boost::begin(rng), boost::end(rng), pred);
BOOST_RANGE_CONCEPT_ASSERT((BinaryPredicateConcept<BinaryPredicate,
BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange>::type,
BOOST_DEDUCED_TYPENAME range_value<const SinglePassRange>::type>));
return ::boost::detail::is_sorted(boost::begin(rng), boost::end(rng), pred);
}
} // namespace range
using range::is_sorted;
using range::is_sorted;
} // namespace boost
#endif // include guard

View File

View File

View File

View File

@@ -0,0 +1,205 @@
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_ANY_RANGE_HPP_INCLUDED
#define BOOST_RANGE_ANY_RANGE_HPP_INCLUDED
#include <boost/config.hpp>
#include <boost/iterator/iterator_categories.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/range/detail/any_iterator.hpp>
#include <boost/range/concepts.hpp>
#include <boost/range/reference.hpp>
#include <boost/range/value_type.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/cast.hpp>
namespace boost
{
namespace range_detail
{
// If T is use_default, return the result of Default, otherwise
// return T.
//
// This is an implementation artifact used to pick intelligent default
// values when the user specified boost::use_default as a template
// parameter.
template<
class T,
class Default
>
struct any_range_default_help
: mpl::eval_if<
is_same<T, use_default>
, Default
, mpl::identity<T>
>
{
};
template<
class WrappedRange
, class Value
, class Reference
>
struct any_range_value_type
{
# ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY
typedef typename any_range_default_help<
Value
, mpl::eval_if<
is_same<Reference, use_default>
, range_value<
typename remove_const<WrappedRange>
::type>
, remove_reference<Reference>
>
>::type type;
# else
typedef typename any_range_default_help<
Value
, range_value<
typename remove_const<WrappedRange>
::type>
>::type type;
# endif
};
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer = use_default
>
class any_range
: public iterator_range<
any_iterator<
Value
, Traversal
, Reference
, Difference
, typename any_range_default_help<
Buffer
, mpl::identity<any_iterator_default_buffer>
>::type
>
>
{
typedef iterator_range<
any_iterator<
Value
, Traversal
, Reference
, Difference
, typename any_range_default_help<
Buffer
, mpl::identity<any_iterator_default_buffer>
>::type
>
> base_type;
struct enabler {};
struct disabler {};
public:
any_range()
{
}
any_range(const any_range& other)
: base_type(other)
{
}
template<class WrappedRange>
any_range(WrappedRange& wrapped_range)
: base_type(boost::begin(wrapped_range),
boost::end(wrapped_range))
{
}
template<class WrappedRange>
any_range(const WrappedRange& wrapped_range)
: base_type(boost::begin(wrapped_range),
boost::end(wrapped_range))
{
}
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
>
any_range(const any_range<
OtherValue
, OtherTraversal
, OtherReference
, OtherDifference
, Buffer
>& other)
: base_type(boost::begin(other), boost::end(other))
{
}
template<class Iterator>
any_range(Iterator first, Iterator last)
: base_type(first, last)
{
}
};
template<
class WrappedRange
, class Value = use_default
, class Traversal = use_default
, class Reference = use_default
, class Difference = use_default
, class Buffer = use_default
>
struct any_range_type_generator
{
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<WrappedRange> ));
typedef any_range<
typename any_range_value_type<
WrappedRange
, Value
, typename any_range_default_help<
Reference
, range_reference<WrappedRange>
>::type
>::type
, typename any_range_default_help<
Traversal
, iterator_traversal<
typename range_iterator<WrappedRange>::type
>
>::type
, typename any_range_default_help<
Reference
, range_reference<WrappedRange>
>::type
, typename any_range_default_help<
Difference
, range_difference<WrappedRange>
>::type
, typename any_range_default_help<
Buffer
, mpl::identity<any_iterator_default_buffer>
>::type
> type;
};
} // namespace range_detail
using range_detail::any_range;
using range_detail::any_range_type_generator;
} // namespace boost
#endif // include guard

View File

@@ -91,6 +91,11 @@ namespace range_detail
} // namespace 'range_detail'
#endif
// Use a ADL namespace barrier to avoid ambiguity with other unqualified
// calls. This is particularly important with C++0x encouraging
// unqualified calls to begin/end.
namespace range_adl_barrier
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type begin( T& r )
@@ -114,19 +119,25 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type begin( const T& r )
return range_begin( r );
}
} // namespace range_adl_barrier
} // namespace boost
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_begin( const T& r )
namespace range_adl_barrier
{
return boost::begin( r );
}
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_begin( const T& r )
{
return boost::range_adl_barrier::begin( r );
}
} // namespace range_adl_barrier
using namespace range_adl_barrier;
} // namespace boost
#endif

8
project/jni/boost/include/boost/range/combine.hpp Executable file → Normal file
View File

@@ -1,3 +1,11 @@
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_COMBINE_HPP
#define BOOST_RANGE_COMBINE_HPP

View File

@@ -98,8 +98,9 @@ namespace boost {
// classes:
//
// The Range algorithms often do not require that the iterators are
// Assignable, but the correct standard conformant iterators
// do require the iterators to be a model of the Assignable concept.
// Assignable or default constructable, but the correct standard
// conformant iterators do require the iterators to be a model of the
// Assignable concept.
// Iterators that contains a functor that is not assignable therefore
// are not correct models of the standard iterator concepts,
// despite being adequate for most algorithms. An example of this
@@ -141,6 +142,26 @@ namespace boost {
BOOST_DEDUCED_TYPENAME SinglePassIteratorConcept::traversal_category,
single_pass_traversal_tag
>));
BOOST_CONCEPT_USAGE(SinglePassIteratorConcept)
{
Iterator i2(++i);
boost::ignore_unused_variable_warning(i2);
// deliberately we are loose with the postfix version for the single pass
// iterator due to the commonly poor adherence to the specification means that
// many algorithms would be unusable, whereas actually without the check they
// work
(void)(i++);
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r1(*i);
boost::ignore_unused_variable_warning(r1);
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r2(*(++i));
boost::ignore_unused_variable_warning(r2);
}
private:
Iterator i;
#endif
};
@@ -160,6 +181,20 @@ namespace boost {
BOOST_DEDUCED_TYPENAME ForwardIteratorConcept::traversal_category,
forward_traversal_tag
>));
BOOST_CONCEPT_USAGE(ForwardIteratorConcept)
{
// See the above note in the SinglePassIteratorConcept about the handling of the
// postfix increment. Since with forward and better iterators there is no need
// for a proxy, we can sensibly require that the dereference result
// is convertible to reference.
Iterator i2(i++);
boost::ignore_unused_variable_warning(i2);
BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r(*(i++));
boost::ignore_unused_variable_warning(r);
}
private:
Iterator i;
#endif
};

View File

@@ -1,13 +1,11 @@
// Boost.Range library
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Copyright Neil Groves 2008. Use, modification and
// distribution is subject to the Boost Software Licence, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// For more information, see http://www.boost.org/libs/range
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED
#define BOOST_RANGE_COUNTING_RANGE_HPP_INCLUDED

View File

@@ -0,0 +1,587 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_HPP_INCLUDED
#include <boost/cast.hpp>
#include <boost/utility.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/or.hpp>
#include <boost/mpl/not.hpp>
#include <boost/type_traits/is_const.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/range/detail/any_iterator_buffer.hpp>
#include <boost/range/detail/any_iterator_interface.hpp>
#include <boost/range/detail/any_iterator_wrapper.hpp>
namespace boost
{
namespace range_detail
{
// metafunction to determine if T is a const reference
template<class T>
struct is_const_reference
{
typedef typename mpl::and_<
typename is_reference<T>::type,
typename is_const<
typename remove_reference<T>::type
>::type
>::type type;
};
// metafunction to determine if T is a mutable reference
template<class T>
struct is_mutable_reference
{
typedef typename mpl::and_<
typename is_reference<T>::type,
typename mpl::not_<
typename is_const<
typename remove_reference<T>::type
>::type
>::type
>::type type;
};
// metafunction to evaluate if a source 'reference' can be
// converted to a target 'reference' as a value.
//
// This is true, when the target reference type is actually
// not a reference, and the source reference is convertible
// to the target type.
template<class SourceReference, class TargetReference>
struct is_convertible_to_value_as_reference
{
typedef typename mpl::and_<
typename mpl::not_<
typename is_reference<TargetReference>::type
>::type
, typename is_convertible<
SourceReference
, TargetReference
>::type
>::type type;
};
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer = any_iterator_default_buffer
>
class any_iterator;
// metafunction to determine if SomeIterator is an
// any_iterator.
//
// This is the general implementation which evaluates to false.
template<class SomeIterator>
struct is_any_iterator
: mpl::bool_<false>
{
};
// specialization of is_any_iterator to return true for
// any_iterator classes regardless of template parameters.
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
struct is_any_iterator<
any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
>
: mpl::bool_<true>
{
};
} // namespace range_detail
namespace detail
{
// Rationale:
// These are specialized since the iterator_facade versions lack
// the requisite typedefs to allow wrapping to determine the types
// if a user copy constructs from a postfix increment.
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
class postfix_increment_proxy<
range_detail::any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
>
{
typedef range_detail::any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
> any_iterator_type;
public:
typedef Value value_type;
typedef typename std::iterator_traits<any_iterator_type>::iterator_category iterator_category;
typedef Difference difference_type;
typedef typename iterator_pointer<any_iterator_type>::type pointer;
typedef Reference reference;
explicit postfix_increment_proxy(any_iterator_type const& x)
: stored_value(*x)
{}
value_type&
operator*() const
{
return this->stored_value;
}
private:
mutable value_type stored_value;
};
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
class writable_postfix_increment_proxy<
range_detail::any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
>
{
typedef range_detail::any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
> any_iterator_type;
public:
typedef Value value_type;
typedef typename std::iterator_traits<any_iterator_type>::iterator_category iterator_category;
typedef Difference difference_type;
typedef typename iterator_pointer<any_iterator_type>::type pointer;
typedef Reference reference;
explicit writable_postfix_increment_proxy(any_iterator_type const& x)
: stored_value(*x)
, stored_iterator(x)
{}
// Dereferencing must return a proxy so that both *r++ = o and
// value_type(*r++) can work. In this case, *r is the same as
// *r++, and the conversion operator below is used to ensure
// readability.
writable_postfix_increment_proxy const&
operator*() const
{
return *this;
}
// Provides readability of *r++
operator value_type&() const
{
return stored_value;
}
// Provides writability of *r++
template <class T>
T const& operator=(T const& x) const
{
*this->stored_iterator = x;
return x;
}
// This overload just in case only non-const objects are writable
template <class T>
T& operator=(T& x) const
{
*this->stored_iterator = x;
return x;
}
// Provides X(r++)
operator any_iterator_type const&() const
{
return stored_iterator;
}
private:
mutable value_type stored_value;
any_iterator_type stored_iterator;
};
}
namespace range_detail
{
template<
class Value
, class Traversal
, class Reference
, class Difference
, class Buffer
>
class any_iterator
: public iterator_facade<
any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
, Value
, Traversal
, Reference
, Difference
>
{
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
, class OtherBuffer
>
friend class any_iterator;
struct enabler {};
struct disabler {};
typedef typename any_iterator_interface_type_generator<
Traversal
, Reference
, Difference
, Buffer
>::type abstract_base_type;
typedef iterator_facade<
any_iterator<
Value
, Traversal
, Reference
, Difference
, Buffer
>
, Value
, Traversal
, Reference
, Difference
> base_type;
typedef Buffer buffer_type;
public:
typedef typename base_type::value_type value_type;
typedef typename base_type::reference reference;
typedef typename base_type::difference_type difference_type;
// Default constructor
any_iterator()
: m_impl(0) {}
// Simple copy construction without conversion
any_iterator(const any_iterator& other)
: base_type(other)
, m_impl(other.m_impl
? other.m_impl->clone(m_buffer)
: 0)
{
}
// Simple assignment operator without conversion
any_iterator& operator=(const any_iterator& other)
{
if (this != &other)
{
if (m_impl)
m_impl->~abstract_base_type();
m_buffer.deallocate();
m_impl = 0;
if (other.m_impl)
m_impl = other.m_impl->clone(m_buffer);
}
return *this;
}
// Implicit conversion from another any_iterator where the
// conversion is from a non-const reference to a const reference
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
>
any_iterator(const any_iterator<
OtherValue,
OtherTraversal,
OtherReference,
OtherDifference,
Buffer
>& other,
typename enable_if<
typename mpl::and_<
typename is_mutable_reference<OtherReference>::type,
typename is_const_reference<Reference>::type
>::type,
enabler
>::type* = 0
)
: m_impl(other.m_impl
? other.m_impl->clone_const_ref(m_buffer)
: 0
)
{
}
// Implicit conversion from another any_iterator where the
// reference types of the source and the target are references
// that are either both const, or both non-const.
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
>
any_iterator(const any_iterator<
OtherValue
, OtherTraversal
, OtherReference
, OtherDifference
, Buffer
>& other,
typename enable_if<
typename mpl::or_<
typename mpl::and_<
typename is_mutable_reference<OtherReference>::type,
typename is_mutable_reference<Reference>::type
>::type,
typename mpl::and_<
typename is_const_reference<OtherReference>::type,
typename is_const_reference<Reference>::type
>::type
>::type,
enabler
>::type* = 0
)
: m_impl(other.m_impl
? other.m_impl->clone(m_buffer)
: 0
)
{
}
// Implicit conversion to an any_iterator that uses a value for
// the reference type.
template<
class OtherValue
, class OtherTraversal
, class OtherReference
, class OtherDifference
>
any_iterator(const any_iterator<
OtherValue
, OtherTraversal
, OtherReference
, OtherDifference
, Buffer
>& other,
typename enable_if<
typename is_convertible_to_value_as_reference<
OtherReference
, Reference
>::type,
enabler
>::type* = 0
)
: m_impl(other.m_impl
? other.m_impl->clone_reference_as_value(m_buffer)
: 0
)
{
}
any_iterator clone() const
{
any_iterator result;
if (m_impl)
result.m_impl = m_impl->clone(result.m_buffer);
return result;
}
any_iterator<
Value
, Traversal
, typename abstract_base_type::const_reference
, Difference
, Buffer
>
clone_const_ref() const
{
typedef any_iterator<
Value
, Traversal
, typename abstract_base_type::const_reference
, Difference
, Buffer
> result_type;
result_type result;
if (m_impl)
result.m_impl = m_impl->clone_const_ref(result.m_buffer);
return result;
}
// implicit conversion and construction from type-erasure-compatible
// iterators
template<class WrappedIterator>
explicit any_iterator(
const WrappedIterator& wrapped_iterator,
typename disable_if<
typename is_any_iterator<WrappedIterator>::type
, disabler
>::type* = 0
)
{
typedef typename any_iterator_wrapper_type_generator<
WrappedIterator
, Traversal
, Reference
, Difference
, Buffer
>::type wrapper_type;
void* ptr = m_buffer.allocate(sizeof(wrapper_type));
m_impl = new(ptr) wrapper_type(wrapped_iterator);
}
~any_iterator()
{
// manually run the destructor, the deallocation is automatically
// handled by the any_iterator_small_buffer base class.
if (m_impl)
m_impl->~abstract_base_type();
}
private:
friend class ::boost::iterator_core_access;
Reference dereference() const
{
BOOST_ASSERT( m_impl );
return m_impl->dereference();
}
bool equal(const any_iterator& other) const
{
return (m_impl == other.m_impl)
|| (m_impl && other.m_impl && m_impl->equal(*other.m_impl));
}
void increment()
{
BOOST_ASSERT( m_impl );
m_impl->increment();
}
void decrement()
{
BOOST_ASSERT( m_impl );
m_impl->decrement();
}
Difference distance_to(const any_iterator& other) const
{
return m_impl && other.m_impl
? m_impl->distance_to(*other.m_impl)
: 0;
}
void advance(Difference offset)
{
BOOST_ASSERT( m_impl );
m_impl->advance(offset);
}
any_iterator& swap(any_iterator& other)
{
BOOST_ASSERT( this != &other );
// grab a temporary copy of the other iterator
any_iterator tmp(other);
// deallocate the other iterator, taking care to obey the
// class-invariants in-case of exceptions later
if (other.m_impl)
{
other.m_impl->~abstract_base_type();
other.m_buffer.deallocate();
other.m_impl = 0;
}
// If this is a non-null iterator then we need to put
// a clone of this iterators impementation into the other
// iterator.
// We can't just swap because of the small buffer optimization.
if (m_impl)
{
other.m_impl = m_impl->clone(other.m_buffer);
m_impl->~abstract_base_type();
m_buffer.deallocate();
m_impl = 0;
}
// assign to this instance a clone of the temporarily held
// tmp which represents the input other parameter at the
// start of execution of this function.
if (tmp.m_impl)
m_impl = tmp.m_impl->clone(m_buffer);
return *this;
}
buffer_type m_buffer;
abstract_base_type* m_impl;
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,117 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_BUFFER_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_BUFFER_HPP_INCLUDED
#include <boost/array.hpp>
#include <boost/assert.hpp>
#include <boost/static_assert.hpp>
#include <boost/utility.hpp>
namespace boost
{
template<std::size_t StackBufferSize>
class any_iterator_buffer
: noncopyable
{
BOOST_STATIC_ASSERT(( StackBufferSize > 0 ));
public:
any_iterator_buffer()
: m_ptr()
{
}
~any_iterator_buffer()
{
delete [] m_ptr;
}
void* allocate(std::size_t bytes)
{
BOOST_ASSERT( !m_ptr );
if (bytes <= StackBufferSize)
return m_buffer.data();
m_ptr = new char[bytes];
return m_ptr;
}
void deallocate()
{
delete [] m_ptr;
m_ptr = 0;
}
private:
// Rationale:
// Do not use inheritance from noncopyable because this causes
// the concepts to erroneous detect the derived any_iterator
// as noncopyable.
any_iterator_buffer(const any_iterator_buffer&);
void operator=(const any_iterator_buffer&);
char* m_ptr;
boost::array<char, StackBufferSize> m_buffer;
};
class any_iterator_heap_only_buffer
: noncopyable
{
public:
any_iterator_heap_only_buffer()
: m_ptr()
{
}
~any_iterator_heap_only_buffer()
{
delete [] m_ptr;
}
void* allocate(std::size_t bytes)
{
BOOST_ASSERT( !m_ptr );
m_ptr = new char[bytes];
return m_ptr;
}
void deallocate()
{
delete [] m_ptr;
m_ptr = 0;
}
private:
char* m_ptr;
};
template<std::size_t StackBufferSize>
class any_iterator_stack_only_buffer
{
BOOST_STATIC_ASSERT(( StackBufferSize > 0 ));
public:
void* allocate(std::size_t bytes)
{
BOOST_ASSERT( bytes <= m_buffer.size() );
return m_buffer.data();
}
void deallocate()
{
}
private:
boost::array<char, StackBufferSize> m_buffer;
};
typedef any_iterator_buffer<64> any_iterator_default_buffer;
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,258 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_INTERFACE_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_INTERFACE_HPP_INCLUDED
#include <boost/range/detail/any_iterator_buffer.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/add_const.hpp>
namespace boost
{
namespace range_detail
{
template<class T>
struct const_reference_type_generator
{
typedef typename mpl::if_<
typename is_reference<T>::type,
typename add_reference<
typename add_const<
typename remove_reference<T>::type
>::type
>::type,
T
>::type type;
};
template<
class Reference
, class Buffer
>
struct any_incrementable_iterator_interface
{
typedef Reference reference;
typedef typename const_reference_type_generator<
Reference
>::type const_reference;
typedef typename remove_const<
typename remove_reference<Reference>::type
>::type reference_as_value_type;
typedef Buffer buffer_type;
virtual ~any_incrementable_iterator_interface() {}
virtual any_incrementable_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_incrementable_iterator_interface<const_reference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_incrementable_iterator_interface<reference_as_value_type, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
virtual void increment() = 0;
};
template<
class Reference
, class Buffer
>
struct any_single_pass_iterator_interface
: any_incrementable_iterator_interface<Reference, Buffer>
{
typedef typename any_incrementable_iterator_interface<Reference, Buffer>::reference reference;
typedef typename any_incrementable_iterator_interface<Reference, Buffer>::const_reference const_reference;
typedef typename any_incrementable_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
typedef typename any_incrementable_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
virtual any_single_pass_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_single_pass_iterator_interface<const_reference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_single_pass_iterator_interface<reference_as_value_type, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
virtual Reference dereference() const = 0;
virtual bool equal(const any_single_pass_iterator_interface& other) const = 0;
};
template<
class Reference
, class Buffer
>
struct any_forward_iterator_interface
: any_single_pass_iterator_interface<Reference, Buffer>
{
typedef typename any_single_pass_iterator_interface<Reference, Buffer>::reference reference;
typedef typename any_single_pass_iterator_interface<Reference, Buffer>::const_reference const_reference;
typedef typename any_single_pass_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
typedef typename any_single_pass_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
virtual any_forward_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_forward_iterator_interface<const_reference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_forward_iterator_interface<reference_as_value_type, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
};
template<
class Reference
, class Buffer
>
struct any_bidirectional_iterator_interface
: any_forward_iterator_interface<Reference, Buffer>
{
typedef typename any_forward_iterator_interface<Reference, Buffer>::reference reference;
typedef typename any_forward_iterator_interface<Reference, Buffer>::const_reference const_reference;
typedef typename any_forward_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
typedef typename any_forward_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
virtual any_bidirectional_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_bidirectional_iterator_interface<const_reference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_bidirectional_iterator_interface<reference_as_value_type, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
virtual void decrement() = 0;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_random_access_iterator_interface
: any_bidirectional_iterator_interface<
Reference
, Buffer
>
{
typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::reference reference;
typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::const_reference const_reference;
typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::buffer_type buffer_type;
typedef typename any_bidirectional_iterator_interface<Reference, Buffer>::reference_as_value_type reference_as_value_type;
typedef Difference difference_type;
virtual any_random_access_iterator_interface*
clone(buffer_type& buffer) const = 0;
virtual any_random_access_iterator_interface<const_reference, Difference, Buffer>*
clone_const_ref(buffer_type& buffer) const = 0;
virtual any_random_access_iterator_interface<reference_as_value_type, Difference, Buffer>*
clone_reference_as_value(buffer_type& buffer) const = 0;
virtual void advance(Difference offset) = 0;
virtual Difference distance_to(const any_random_access_iterator_interface& other) const = 0;
};
template<
class Traversal
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator;
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
incrementable_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_incrementable_iterator_interface<Reference, Buffer> type;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
single_pass_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_single_pass_iterator_interface<Reference, Buffer> type;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
forward_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_forward_iterator_interface<Reference, Buffer> type;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
bidirectional_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_bidirectional_iterator_interface<Reference, Buffer> type;
};
template<
class Reference
, class Difference
, class Buffer
>
struct any_iterator_interface_type_generator<
random_access_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_random_access_iterator_interface<
Reference
, Difference
, Buffer
> type;
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -0,0 +1,590 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED
#define BOOST_RANGE_DETAIL_ANY_ITERATOR_WRAPPER_HPP_INCLUDED
#include <boost/range/config.hpp>
#include <boost/range/detail/any_iterator_interface.hpp>
namespace boost
{
namespace range_detail
{
template<
class WrappedIterator
, class Reference
, class Buffer
>
class any_incrementable_iterator_wrapper
: public any_incrementable_iterator_interface<
Reference
, Buffer
>
{
BOOST_RANGE_CONCEPT_ASSERT(( IncrementableIteratorConcept<WrappedIterator> ));
public:
typedef WrappedIterator wrapped_type;
BOOST_STATIC_ASSERT(( is_convertible<
typename iterator_reference<WrappedIterator>::type
, Reference
>::value ));
any_incrementable_iterator_wrapper()
: m_it()
{}
explicit any_incrementable_iterator_wrapper(wrapped_type it)
: m_it(it)
{}
// any_incrementable_iterator implementation
virtual any_incrementable_iterator_wrapper* clone(
typename any_incrementable_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_incrementable_iterator_wrapper(m_it);
}
virtual any_incrementable_iterator_wrapper<
WrappedIterator
, typename any_incrementable_iterator_wrapper::const_reference
, Buffer
>* clone_const_ref(
typename any_incrementable_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_incrementable_iterator_wrapper<
WrappedIterator
, typename any_incrementable_iterator_wrapper::const_reference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_incrementable_iterator_wrapper<
WrappedIterator
, typename any_incrementable_iterator_wrapper::reference_as_value_type
, Buffer
>* clone_reference_as_value(
typename any_incrementable_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_incrementable_iterator_wrapper<
WrappedIterator
, typename any_incrementable_iterator_wrapper::reference_as_value_type
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
private:
wrapped_type m_it;
};
template<
class WrappedIterator
, class Reference
, class Buffer
>
class any_single_pass_iterator_wrapper
: public any_single_pass_iterator_interface<
Reference
, Buffer
>
{
struct disabler {};
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassIteratorConcept<WrappedIterator> ));
public:
any_single_pass_iterator_wrapper()
: m_it()
{}
explicit any_single_pass_iterator_wrapper(const WrappedIterator& it)
: m_it(it)
{}
// any_single_pass_iterator_interface<Reference> implementation
virtual any_single_pass_iterator_wrapper* clone(
typename any_single_pass_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_single_pass_iterator_wrapper(m_it);
}
virtual any_single_pass_iterator_wrapper<
WrappedIterator
, typename any_single_pass_iterator_wrapper::const_reference
, Buffer
>* clone_const_ref(
typename any_single_pass_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_single_pass_iterator_wrapper<
WrappedIterator
, typename any_single_pass_iterator_wrapper::const_reference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_single_pass_iterator_wrapper<
WrappedIterator
, typename any_single_pass_iterator_wrapper::reference_as_value_type
, Buffer
>* clone_reference_as_value(
typename any_single_pass_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_single_pass_iterator_wrapper<
WrappedIterator
, typename any_single_pass_iterator_wrapper::reference_as_value_type
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
{
return m_it == boost::polymorphic_downcast<const any_single_pass_iterator_wrapper*>(&other)->m_it;
}
virtual Reference dereference() const
{
return *m_it;
}
private:
WrappedIterator m_it;
};
template<
class WrappedIterator
, class Reference
, class Buffer
>
class any_forward_iterator_wrapper
: public any_forward_iterator_interface<
Reference
, Buffer
>
{
BOOST_RANGE_CONCEPT_ASSERT(( ForwardIteratorConcept<WrappedIterator> ));
public:
any_forward_iterator_wrapper()
: m_it()
{}
explicit any_forward_iterator_wrapper(const WrappedIterator& it)
: m_it(it)
{}
// any_forward_iterator_interface<Reference> implementation
virtual any_forward_iterator_wrapper* clone(
typename any_forward_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_forward_iterator_wrapper(m_it);
}
virtual any_forward_iterator_wrapper<
WrappedIterator
, typename any_forward_iterator_wrapper::const_reference
, Buffer
>* clone_const_ref(
typename any_forward_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_forward_iterator_wrapper<
WrappedIterator
, typename any_forward_iterator_wrapper::const_reference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_forward_iterator_wrapper<
WrappedIterator
, typename any_forward_iterator_wrapper::reference_as_value_type
, Buffer
>* clone_reference_as_value(
typename any_forward_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_forward_iterator_wrapper<
WrappedIterator
, typename any_forward_iterator_wrapper::reference_as_value_type
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
{
return m_it == boost::polymorphic_downcast<const any_forward_iterator_wrapper*>(&other)->m_it;
}
virtual Reference dereference() const
{
return *m_it;
}
private:
WrappedIterator m_it;
};
template<
class WrappedIterator
, class Reference
, class Buffer
>
class any_bidirectional_iterator_wrapper
: public any_bidirectional_iterator_interface<
Reference
, Buffer
>
{
BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalIteratorConcept<WrappedIterator> ));
public:
any_bidirectional_iterator_wrapper()
: m_it()
{
}
explicit any_bidirectional_iterator_wrapper(const WrappedIterator& it)
: m_it(it)
{
}
virtual any_bidirectional_iterator_wrapper* clone(
typename any_bidirectional_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_bidirectional_iterator_wrapper(*this);
}
virtual any_bidirectional_iterator_wrapper<
WrappedIterator
, typename any_bidirectional_iterator_wrapper::const_reference
, Buffer
>* clone_const_ref(
typename any_bidirectional_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_bidirectional_iterator_wrapper<
WrappedIterator
, typename any_bidirectional_iterator_wrapper::const_reference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_bidirectional_iterator_wrapper<
WrappedIterator
, typename any_bidirectional_iterator_wrapper::reference_as_value_type
, Buffer
>* clone_reference_as_value(
typename any_bidirectional_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_bidirectional_iterator_wrapper<
WrappedIterator
, typename any_bidirectional_iterator_wrapper::reference_as_value_type
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
virtual void decrement()
{
--m_it;
}
virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
{
return m_it == boost::polymorphic_downcast<const any_bidirectional_iterator_wrapper*>(&other)->m_it;
}
virtual Reference dereference() const
{
return *m_it;
}
private:
WrappedIterator m_it;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
class any_random_access_iterator_wrapper
: public any_random_access_iterator_interface<
Reference
, Difference
, Buffer
>
{
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessIteratorConcept<WrappedIterator> ));
public:
typedef Difference difference_type;
any_random_access_iterator_wrapper()
: m_it()
{
}
explicit any_random_access_iterator_wrapper(const WrappedIterator& other)
: m_it(other)
{
}
virtual any_random_access_iterator_wrapper* clone(
typename any_random_access_iterator_wrapper::buffer_type& buffer
) const
{
return new (buffer.allocate(sizeof(*this)))
any_random_access_iterator_wrapper(*this);
}
virtual any_random_access_iterator_wrapper<
WrappedIterator
, typename any_random_access_iterator_wrapper::const_reference
, Difference
, Buffer
>* clone_const_ref(
typename any_random_access_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_random_access_iterator_wrapper<
WrappedIterator
, typename any_random_access_iterator_wrapper::const_reference
, Difference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual any_random_access_iterator_wrapper<
WrappedIterator
, typename any_random_access_iterator_wrapper::reference_as_value_type
, Difference
, Buffer
>* clone_reference_as_value(
typename any_random_access_iterator_wrapper::buffer_type& buffer
) const
{
typedef any_random_access_iterator_wrapper<
WrappedIterator
, typename any_random_access_iterator_wrapper::reference_as_value_type
, Difference
, Buffer
> result_type;
return new (buffer.allocate(sizeof(result_type)))
result_type(m_it);
}
virtual void increment()
{
++m_it;
}
virtual bool equal(const any_single_pass_iterator_interface<Reference, Buffer>& other) const
{
return m_it == boost::polymorphic_downcast<const any_random_access_iterator_wrapper*>(&other)->m_it;
}
virtual void decrement()
{
--m_it;
}
virtual void advance(Difference offset)
{
m_it += offset;
}
virtual Reference dereference() const
{
return *m_it;
}
virtual Difference distance_to(const any_random_access_iterator_interface<Reference, Difference, Buffer>& other) const
{
return boost::polymorphic_downcast<const any_random_access_iterator_wrapper*>(&other)->m_it - m_it;
}
private:
WrappedIterator m_it;
};
template<
class WrappedIterator
, class Traversal
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator;
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, incrementable_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_incrementable_iterator_wrapper<
WrappedIterator
, Reference
, Buffer
> type;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, single_pass_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_single_pass_iterator_wrapper<
WrappedIterator
, Reference
, Buffer
> type;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, forward_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_forward_iterator_wrapper<
WrappedIterator
, Reference
, Buffer
> type;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, bidirectional_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_bidirectional_iterator_wrapper<
WrappedIterator
, Reference
, Buffer
> type;
};
template<
class WrappedIterator
, class Reference
, class Difference
, class Buffer
>
struct any_iterator_wrapper_type_generator<
WrappedIterator
, random_access_traversal_tag
, Reference
, Difference
, Buffer
>
{
typedef any_random_access_iterator_wrapper<
WrappedIterator
, Reference
, Difference
, Buffer
> type;
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -19,9 +19,9 @@
# include <boost/range/value_type.hpp>
#endif
namespace boost
namespace boost
{
namespace range_detail
{
template< typename T >
@@ -30,7 +30,7 @@ namespace boost
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<std_container_>
{
@@ -40,11 +40,11 @@ namespace boost
return c.begin();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<std_pair_>
{
@@ -54,11 +54,11 @@ namespace boost
return p.first;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_begin<array_>
{
@@ -78,14 +78,16 @@ namespace boost
};
} // namespace 'range_detail'
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
begin( C& c )
namespace range_adl_barrier
{
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
begin( C& c )
{
return range_detail::range_begin< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
}
} // namespace 'boost'

View File

@@ -5,6 +5,9 @@
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Acknowledgements:
// aschoedl supplied a fix to supply the level of interoperability I had
// originally intended, but failed to implement.
//
// For more information, see http://www.boost.org/libs/range/
//
@@ -19,12 +22,12 @@ namespace boost
{
template<class IteratorTraversalTag1, class IteratorTraversalTag2>
struct demote_iterator_traversal_tag
struct inner_demote_iterator_traversal_tag
{
};
#define BOOST_DEMOTE_TRAVERSAL_TAG( Tag1, Tag2, ResultTag ) \
template<> struct demote_iterator_traversal_tag< Tag1 , Tag2 > \
template<> struct inner_demote_iterator_traversal_tag< Tag1 , Tag2 > \
{ \
typedef ResultTag type; \
};
@@ -73,6 +76,15 @@ BOOST_DEMOTE_TRAVERSAL_TAG( random_access_traversal_tag, random_access_traversal
#undef BOOST_DEMOTE_TRAVERSAL_TAG
template<class IteratorTraversalTag1, class IteratorTraversalTag2>
struct demote_iterator_traversal_tag
: inner_demote_iterator_traversal_tag<
typename boost::detail::pure_traversal_tag< IteratorTraversalTag1 >::type,
typename boost::detail::pure_traversal_tag< IteratorTraversalTag2 >::type
>
{
};
} // namespace range_detail
} // namespace boost

View File

@@ -134,8 +134,8 @@ namespace boost
#include <boost/range/detail/begin.hpp>
#include <boost/range/detail/end.hpp>
#include <boost/range/detail/size_type>
#include <boost/range/detail/value_type>
#include <boost/range/detail/size_type.hpp>
#include <boost/range/detail/value_type.hpp>
#include <boost/range/detail/common.hpp>
namespace boost

View File

@@ -24,7 +24,7 @@
# include <boost/range/detail/remove_extent.hpp>
# endif
namespace boost
namespace boost
{
namespace range_detail
{
@@ -34,39 +34,39 @@ namespace boost
//////////////////////////////////////////////////////////////////////
// default
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_container_>
{
template< typename C >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
fun( C& c )
{
return c.end();
};
};
//////////////////////////////////////////////////////////////////////
// pair
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<std_pair_>
{
template< typename P >
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
fun( const P& p )
{
return p.second;
}
};
//////////////////////////////////////////////////////////////////////
// array
//////////////////////////////////////////////////////////////////////
template<>
struct range_end<array_>
struct range_end<array_>
{
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template< typename T, std::size_t sz >
@@ -82,16 +82,19 @@ namespace boost
}
#endif
};
} // namespace 'range_detail'
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
end( C& c )
namespace range_adl_barrier
{
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
template< typename C >
inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
end( C& c )
{
return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
}
} // namespace range_adl_barrier
} // namespace 'boost'
# endif // VC6

View File

View File

@@ -5,6 +5,9 @@
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// Acknowledgements:
// aschoedl contributed an improvement to the determination
// of the Reference type parameter.
//
// For more information, see http://www.boost.org/libs/range/
//
@@ -120,7 +123,32 @@ private:
template<typename Iterator1
, typename Iterator2
, typename ValueType = typename iterator_value<Iterator1>::type
, typename Reference = typename iterator_reference<Iterator1>::type
// find least demanding, commonly supported reference type, in the order &, const&, and by-value:
, typename Reference = typename mpl::if_c<
!is_reference<typename iterator_reference<Iterator1>::type>::value
|| !is_reference<typename iterator_reference<Iterator2>::type>::value,
typename remove_const<
typename remove_reference<
typename iterator_reference<Iterator1>::type
>::type
>::type,
typename mpl::if_c<
is_const<
typename remove_reference<
typename iterator_reference<Iterator1>::type
>::type
>::value
|| is_const<
typename remove_reference<
typename iterator_reference<Iterator2>::type
>::type
>::value,
typename add_const<
typename iterator_reference<Iterator2>::type
>::type,
typename iterator_reference<Iterator1>::type
>::type
>::type
, typename Traversal = typename demote_iterator_traversal_tag<
typename iterator_traversal<Iterator1>::type
, typename iterator_traversal<Iterator2>::type>::type

View File

View File

View File

@@ -0,0 +1,72 @@
// This header intentionally has no include guards.
//
// Copyright (c) 2010 Neil Groves
// Distributed under the Boost Software License, Version 1.0.
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
//
// This code utilises the experience gained during the evolution of
// <boost/smart_ptr/operator_bool.hpp>
#ifndef BOOST_RANGE_SAFE_BOOL_INCLUDED_HPP
#define BOOST_RANGE_SAFE_BOOL_INCLUDED_HPP
#include <boost/config.hpp>
#include <boost/range/config.hpp>
namespace boost
{
namespace range_detail
{
template<class DataMemberPtr>
class safe_bool
{
public:
typedef safe_bool this_type;
#if (defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, < 0x570)) || defined(__CINT_)
typedef bool unspecified_bool_type;
static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
{
return x;
}
#elif defined(_MANAGED)
static void unspecified_bool(this_type***)
{
}
typedef void(*unspecified_bool_type)(this_type***);
static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
{
return x ? unspecified_bool : 0;
}
#elif \
( defined(__MWERKS__) && BOOST_WORKAROUND(__MWERKS__, < 0x3200) ) || \
( defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 304) ) || \
( defined(__SUNPRO_CC) && BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) )
typedef bool (this_type::*unspecified_bool_type)() const;
static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr)
{
return x ? &this_type::detail_safe_bool_member_fn : 0;
}
private:
bool detail_safe_bool_member_fn() const { return false; }
#else
typedef DataMemberPtr unspecified_bool_type;
static unspecified_bool_type to_unspecified_bool(const bool x, DataMemberPtr p)
{
return x ? p : 0;
}
#endif
private:
safe_bool();
safe_bool(const safe_bool&);
void operator=(const safe_bool&);
~safe_bool();
};
} // namespace range_detail
} // namespace boost
#endif // include guard

View File

@@ -88,6 +88,9 @@ namespace range_detail
} // namespace 'range_detail'
#endif
namespace range_adl_barrier
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
{
@@ -110,22 +113,24 @@ inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
return range_end( r );
}
} // namespace range_adl_barrier
} // namespace 'boost'
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
namespace boost
{
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_end( const T& r )
namespace range_adl_barrier
{
return boost::end( r );
}
}
template< class T >
inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
const_end( const T& r )
{
return boost::range_adl_barrier::end( r );
}
} // namespace range_adl_barrier
using namespace range_adl_barrier;
} // namespace boost
#endif

View File

@@ -0,0 +1,62 @@
// Boost.Range library
//
// Copyright Neil Groves 2010. Use, modification and
// distribution is subject to the Boost Software License, Version
// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org/libs/range/
//
#ifndef BOOST_RANGE_HAS_ITERATOR_HPP_INCLUDED
#define BOOST_RANGE_HAS_ITERATOR_HPP_INCLUDED
#include <boost/mpl/bool.hpp>
#include <boost/mpl/has_xxx.hpp>
#include <boost/range/iterator.hpp>
#include <boost/utility.hpp>
namespace boost
{
namespace range_detail
{
BOOST_MPL_HAS_XXX_TRAIT_DEF(type)
template<class T, class Enabler = void>
struct has_range_iterator_impl
: boost::mpl::false_
{
};
template<class T>
struct has_range_iterator_impl<T, BOOST_DEDUCED_TYPENAME enable_if< has_type< range_mutable_iterator<T> > >::type>
: boost::mpl::true_
{
};
template<class T, class Enabler = void>
struct has_range_const_iterator_impl
: boost::mpl::false_
{
};
template<class T>
struct has_range_const_iterator_impl<T, BOOST_DEDUCED_TYPENAME enable_if< has_type< range_const_iterator<T> > >::type>
: boost::mpl::true_
{
};
} // namespace range_detail
template<class T>
struct has_range_iterator
: range_detail::has_range_iterator_impl<T>
{};
template<class T>
struct has_range_const_iterator
: range_detail::has_range_const_iterator_impl<T>
{};
} // namespace boost
#endif // include guard

View File

@@ -124,13 +124,11 @@ namespace boost
typedef typename base_t::difference_type difference_type;
typedef typename base_t::reference reference;
integer_iterator_with_step(value_type first, value_type step, difference_type step_size)
integer_iterator_with_step(value_type first, difference_type step, value_type step_size)
: m_first(first)
, m_step(step)
, m_step_size(step_size)
{
BOOST_ASSERT( step >= 0 );
BOOST_ASSERT( step_size != 0 );
}
private:
@@ -213,16 +211,18 @@ namespace boost
{
BOOST_ASSERT( step_size != 0 );
BOOST_ASSERT( (step_size > 0) ? (last >= first) : (last <= first) );
typedef typename range_detail::integer_iterator_with_step<Integer> iterator_t;
const std::ptrdiff_t last_step
= (static_cast<std::ptrdiff_t>(last) - static_cast<std::ptrdiff_t>(first))
/ (static_cast<std::ptrdiff_t>(step_size));
const std::ptrdiff_t sz = static_cast<std::ptrdiff_t>(step_size >= 0 ? step_size : -step_size);
const Integer l = step_size >= 0 ? last : first;
const Integer f = step_size >= 0 ? first : last;
const std::ptrdiff_t num_steps = (l + ((l-f) % sz) - f) / sz;
BOOST_ASSERT(num_steps >= 0);
return strided_integer_range<Integer>(
iterator_t(first, 0, step_size),
iterator_t(first, last_step, step_size));
iterator_t(first, num_steps, step_size));
}
} // namespace boost

Some files were not shown because too many files have changed in this diff Show More