forked from boostorg/range
merge branch develop
This commit is contained in:
@ -62,54 +62,44 @@ namespace boost
|
||||
, pred_t(pred)
|
||||
, m_last(last)
|
||||
{
|
||||
move_to_next_valid();
|
||||
}
|
||||
|
||||
template<class OtherIter>
|
||||
skip_iterator( const skip_iterator<OtherIter, pred_t, default_pass>& other )
|
||||
: base_t(other.base())
|
||||
, pred_t(other)
|
||||
, m_last(other.m_last) {}
|
||||
|
||||
void move_to_next_valid()
|
||||
, m_last(other.m_last)
|
||||
{
|
||||
iter_t& it = this->base_reference();
|
||||
pred_t& bi_pred = *this;
|
||||
if (it != m_last)
|
||||
{
|
||||
if (default_pass)
|
||||
{
|
||||
iter_t nxt = ::boost::next(it);
|
||||
while (nxt != m_last && !bi_pred(*it, *nxt))
|
||||
{
|
||||
++it;
|
||||
++nxt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iter_t nxt = ::boost::next(it);
|
||||
for(; nxt != m_last; ++it, ++nxt)
|
||||
{
|
||||
if (bi_pred(*it, *nxt))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nxt == m_last)
|
||||
{
|
||||
it = m_last;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void increment()
|
||||
{
|
||||
iter_t& it = this->base_reference();
|
||||
BOOST_ASSERT( it != m_last );
|
||||
pred_t& bi_pred = *this;
|
||||
iter_t prev = it;
|
||||
++it;
|
||||
move_to_next_valid();
|
||||
if (it != m_last)
|
||||
{
|
||||
if (default_pass)
|
||||
{
|
||||
while (it != m_last && !bi_pred(*prev, *it))
|
||||
{
|
||||
++it;
|
||||
++prev;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (; it != m_last; ++it, ++prev)
|
||||
{
|
||||
if (bi_pred(*prev, *it))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
iter_t m_last;
|
||||
|
@ -34,7 +34,8 @@ namespace boost
|
||||
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)))
|
||||
: base_t(boost::next(boost::begin(rng), t),
|
||||
boost::next(boost::begin(rng), u))
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include <boost/range/adaptor/argument_fwd.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <iterator>
|
||||
|
||||
namespace boost
|
||||
@ -23,59 +23,102 @@ namespace boost
|
||||
// strided_iterator for wrapping a forward traversal iterator
|
||||
template<class BaseIterator, class Category>
|
||||
class strided_iterator
|
||||
: public iterator_adaptor<
|
||||
: public iterator_facade<
|
||||
strided_iterator<BaseIterator, Category>
|
||||
, BaseIterator
|
||||
, use_default
|
||||
, boost::forward_traversal_tag
|
||||
, typename iterator_value<BaseIterator>::type
|
||||
, forward_traversal_tag
|
||||
, typename iterator_reference<BaseIterator>::type
|
||||
, typename iterator_difference<BaseIterator>::type
|
||||
>
|
||||
{
|
||||
friend class ::boost::iterator_core_access;
|
||||
|
||||
typedef iterator_adaptor<
|
||||
strided_iterator<BaseIterator, Category>
|
||||
, BaseIterator
|
||||
, use_default
|
||||
, boost::forward_traversal_tag
|
||||
> super_t;
|
||||
typedef iterator_facade<
|
||||
strided_iterator<BaseIterator, Category>
|
||||
, typename iterator_value<BaseIterator>::type
|
||||
, forward_traversal_tag
|
||||
, typename iterator_reference<BaseIterator>::type
|
||||
, typename iterator_difference<BaseIterator>::type
|
||||
> super_t;
|
||||
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
|
||||
typedef typename super_t::difference_type difference_type;
|
||||
typedef typename super_t::reference reference;
|
||||
typedef BaseIterator base_iterator;
|
||||
typedef std::forward_iterator_tag iterator_category;
|
||||
|
||||
strided_iterator()
|
||||
: m_last()
|
||||
: m_it()
|
||||
, m_last()
|
||||
, m_stride()
|
||||
{
|
||||
}
|
||||
|
||||
strided_iterator(base_iterator first, base_iterator it, base_iterator last, difference_type stride)
|
||||
: super_t(it)
|
||||
strided_iterator(base_iterator it,
|
||||
base_iterator last,
|
||||
difference_type stride)
|
||||
: m_it(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)
|
||||
strided_iterator(
|
||||
const strided_iterator<OtherIterator, Category>& other,
|
||||
typename enable_if_convertible<
|
||||
OtherIterator,
|
||||
base_iterator
|
||||
>::type* = 0
|
||||
)
|
||||
: m_it(other.base())
|
||||
, 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; }
|
||||
base_iterator base() const
|
||||
{
|
||||
return m_it;
|
||||
}
|
||||
|
||||
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;
|
||||
for (difference_type i = 0;
|
||||
(m_it != m_last) && (i < m_stride); ++i)
|
||||
{
|
||||
++m_it;
|
||||
}
|
||||
}
|
||||
|
||||
reference dereference() const
|
||||
{
|
||||
return *m_it;
|
||||
}
|
||||
|
||||
template<class OtherIterator>
|
||||
bool equal(
|
||||
const strided_iterator<OtherIterator, Category>& other,
|
||||
typename enable_if_convertible<
|
||||
OtherIterator,
|
||||
base_iterator
|
||||
>::type* = 0) const
|
||||
{
|
||||
return m_it == other.m_it;
|
||||
}
|
||||
|
||||
base_iterator m_it;
|
||||
base_iterator m_last;
|
||||
difference_type m_stride;
|
||||
};
|
||||
@ -83,214 +126,514 @@ namespace boost
|
||||
// strided_iterator for wrapping a bidirectional iterator
|
||||
template<class BaseIterator>
|
||||
class strided_iterator<BaseIterator, bidirectional_traversal_tag>
|
||||
: public iterator_adaptor<
|
||||
: public iterator_facade<
|
||||
strided_iterator<BaseIterator, bidirectional_traversal_tag>
|
||||
, BaseIterator
|
||||
, use_default
|
||||
, bidirectional_traversal_tag
|
||||
, typename iterator_value<BaseIterator>::type
|
||||
, bidirectional_traversal_tag
|
||||
, typename iterator_reference<BaseIterator>::type
|
||||
, typename iterator_difference<BaseIterator>::type
|
||||
>
|
||||
{
|
||||
friend class ::boost::iterator_core_access;
|
||||
|
||||
typedef iterator_adaptor<
|
||||
strided_iterator<BaseIterator, bidirectional_traversal_tag>
|
||||
, BaseIterator
|
||||
, use_default
|
||||
, bidirectional_traversal_tag
|
||||
> super_t;
|
||||
typedef iterator_facade<
|
||||
strided_iterator<BaseIterator, bidirectional_traversal_tag>
|
||||
, typename iterator_value<BaseIterator>::type
|
||||
, bidirectional_traversal_tag
|
||||
, typename iterator_reference<BaseIterator>::type
|
||||
, typename iterator_difference<BaseIterator>::type
|
||||
> super_t;
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<BaseIterator>::difference_type difference_type;
|
||||
typedef typename super_t::difference_type difference_type;
|
||||
typedef typename super_t::reference reference;
|
||||
typedef BaseIterator base_iterator;
|
||||
typedef typename boost::make_unsigned<difference_type>::type
|
||||
size_type;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
|
||||
strided_iterator()
|
||||
: m_first()
|
||||
, m_last()
|
||||
: m_it()
|
||||
, m_offset()
|
||||
, m_index()
|
||||
, 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)
|
||||
strided_iterator(base_iterator it,
|
||||
size_type index,
|
||||
difference_type stride)
|
||||
: m_it(it)
|
||||
, m_offset()
|
||||
, m_index(index)
|
||||
, m_stride(stride)
|
||||
{
|
||||
if (stride && ((m_index % stride) != 0))
|
||||
m_index += (stride - (m_index % 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())
|
||||
strided_iterator(
|
||||
const strided_iterator<
|
||||
OtherIterator,
|
||||
bidirectional_traversal_tag
|
||||
>& other,
|
||||
typename enable_if_convertible<
|
||||
OtherIterator,
|
||||
base_iterator
|
||||
>::type* = 0
|
||||
)
|
||||
: m_it(other.base())
|
||||
, m_offset(other.get_offset())
|
||||
, 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; }
|
||||
base_iterator base() const
|
||||
{
|
||||
return m_it;
|
||||
}
|
||||
|
||||
difference_type get_offset() const
|
||||
{
|
||||
return m_offset;
|
||||
}
|
||||
|
||||
size_type get_index() const
|
||||
{
|
||||
return m_index;
|
||||
}
|
||||
|
||||
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;
|
||||
m_offset += m_stride;
|
||||
}
|
||||
|
||||
void decrement()
|
||||
{
|
||||
base_iterator& it = this->base_reference();
|
||||
for (difference_type i = 0; (it != m_first) && (i < m_stride); ++i)
|
||||
--it;
|
||||
m_offset -= m_stride;
|
||||
}
|
||||
|
||||
base_iterator m_first;
|
||||
base_iterator m_last;
|
||||
reference dereference() const
|
||||
{
|
||||
update();
|
||||
return *m_it;
|
||||
}
|
||||
|
||||
void update() const
|
||||
{
|
||||
std::advance(m_it, m_offset);
|
||||
m_index += m_offset;
|
||||
m_offset = 0;
|
||||
}
|
||||
|
||||
template<class OtherIterator>
|
||||
bool equal(
|
||||
const strided_iterator<
|
||||
OtherIterator,
|
||||
bidirectional_traversal_tag
|
||||
>& other,
|
||||
typename enable_if_convertible<
|
||||
OtherIterator,
|
||||
base_iterator
|
||||
>::type* = 0) const
|
||||
{
|
||||
return (m_index + m_offset) ==
|
||||
(other.get_index() + other.get_offset());
|
||||
}
|
||||
|
||||
mutable base_iterator m_it;
|
||||
mutable difference_type m_offset;
|
||||
mutable size_type m_index;
|
||||
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
|
||||
>
|
||||
: public iterator_facade<
|
||||
strided_iterator<BaseIterator, random_access_traversal_tag>
|
||||
, typename iterator_value<BaseIterator>::type
|
||||
, random_access_traversal_tag
|
||||
, typename iterator_reference<BaseIterator>::type
|
||||
, typename iterator_difference<BaseIterator>::type
|
||||
>
|
||||
{
|
||||
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;
|
||||
typedef iterator_facade<
|
||||
strided_iterator<BaseIterator, random_access_traversal_tag>
|
||||
, typename iterator_value<BaseIterator>::type
|
||||
, random_access_traversal_tag
|
||||
, typename iterator_reference<BaseIterator>::type
|
||||
, typename iterator_difference<BaseIterator>::type
|
||||
> super_t;
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME super_t::difference_type difference_type;
|
||||
typedef typename super_t::difference_type difference_type;
|
||||
typedef typename super_t::reference reference;
|
||||
typedef BaseIterator base_iterator;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
|
||||
strided_iterator()
|
||||
: m_first()
|
||||
, m_last()
|
||||
: m_it()
|
||||
, m_first()
|
||||
, m_index(0)
|
||||
, m_stride()
|
||||
{
|
||||
}
|
||||
|
||||
strided_iterator(BaseIterator first, BaseIterator it, BaseIterator last, difference_type stride)
|
||||
: super_t(it)
|
||||
strided_iterator(
|
||||
base_iterator first,
|
||||
base_iterator it,
|
||||
difference_type stride
|
||||
)
|
||||
: m_it(it)
|
||||
, m_first(first)
|
||||
, m_last(last)
|
||||
, m_index(stride ? (it - first) / stride : 0)
|
||||
, m_index(stride ? (it - first) : difference_type())
|
||||
, m_stride(stride)
|
||||
{
|
||||
if (stride && ((m_index % stride) != 0))
|
||||
m_index += (stride - (m_index % 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())
|
||||
strided_iterator(
|
||||
const strided_iterator<
|
||||
OtherIterator,
|
||||
random_access_traversal_tag
|
||||
>& other,
|
||||
typename enable_if_convertible<
|
||||
OtherIterator,
|
||||
base_iterator
|
||||
>::type* = 0
|
||||
)
|
||||
: m_it(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; }
|
||||
base_iterator base_begin() const
|
||||
{
|
||||
return m_first;
|
||||
}
|
||||
|
||||
base_iterator base() const
|
||||
{
|
||||
return m_it;
|
||||
}
|
||||
|
||||
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;
|
||||
m_index += (m_stride * offset);
|
||||
}
|
||||
|
||||
// Implementation detail: only update the actual underlying iterator
|
||||
// at the point of dereference. This is done so that the increment
|
||||
// and decrement can overshoot the valid sequence as is required
|
||||
// by striding. Since we can do all comparisons just with the index
|
||||
// simply, and all dereferences must be within the valid range.
|
||||
void update() const
|
||||
{
|
||||
m_it = 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
|
||||
difference_type distance_to(
|
||||
const strided_iterator<
|
||||
OtherIterator,
|
||||
random_access_traversal_tag
|
||||
>& other,
|
||||
typename enable_if_convertible<
|
||||
OtherIterator, base_iterator>::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;
|
||||
BOOST_ASSERT((other.m_index - m_index) % m_stride == difference_type());
|
||||
return (other.m_index - m_index) / m_stride;
|
||||
}
|
||||
|
||||
bool equal(const strided_iterator& other) const
|
||||
template<class OtherIterator>
|
||||
bool equal(
|
||||
const strided_iterator<
|
||||
OtherIterator,
|
||||
random_access_traversal_tag
|
||||
>& other,
|
||||
typename enable_if_convertible<
|
||||
OtherIterator, base_iterator>::type* = 0) const
|
||||
{
|
||||
return this->base() == other.base();
|
||||
return m_index == other.m_index;
|
||||
}
|
||||
|
||||
reference dereference() const
|
||||
{
|
||||
update();
|
||||
return *m_it;
|
||||
}
|
||||
|
||||
private:
|
||||
mutable base_iterator m_it;
|
||||
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)
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
forward_traversal_tag
|
||||
>
|
||||
make_begin_strided_iterator(
|
||||
Rng& rng,
|
||||
Difference stride,
|
||||
forward_traversal_tag)
|
||||
{
|
||||
BOOST_ASSERT( stride >= 0 );
|
||||
typedef BOOST_DEDUCED_TYPENAME iterator_traversal<BaseIterator>::type traversal_tag;
|
||||
return strided_iterator<BaseIterator, traversal_tag>(first, it, last, stride);
|
||||
return strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
forward_traversal_tag
|
||||
>(boost::begin(rng), boost::end(rng), stride);
|
||||
}
|
||||
|
||||
template< class Rng
|
||||
, class Category = BOOST_DEDUCED_TYPENAME iterator_traversal<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type
|
||||
>::type
|
||||
>
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
forward_traversal_tag
|
||||
>
|
||||
make_begin_strided_iterator(
|
||||
const Rng& rng,
|
||||
Difference stride,
|
||||
forward_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
forward_traversal_tag
|
||||
>(boost::begin(rng), boost::end(rng), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
forward_traversal_tag
|
||||
>
|
||||
make_end_strided_iterator(
|
||||
Rng& rng,
|
||||
Difference stride,
|
||||
forward_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
forward_traversal_tag
|
||||
>(boost::end(rng), boost::end(rng), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
forward_traversal_tag
|
||||
>
|
||||
make_end_strided_iterator(
|
||||
const Rng& rng,
|
||||
Difference stride,
|
||||
forward_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
forward_traversal_tag
|
||||
>(boost::end(rng), boost::end(rng), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
bidirectional_traversal_tag
|
||||
>
|
||||
make_begin_strided_iterator(
|
||||
Rng& rng,
|
||||
Difference stride,
|
||||
bidirectional_traversal_tag)
|
||||
{
|
||||
typedef typename range_difference<Rng>::type difference_type;
|
||||
|
||||
return strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
bidirectional_traversal_tag
|
||||
>(boost::begin(rng), difference_type(), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
bidirectional_traversal_tag
|
||||
>
|
||||
make_begin_strided_iterator(
|
||||
const Rng& rng,
|
||||
Difference stride,
|
||||
bidirectional_traversal_tag)
|
||||
{
|
||||
typedef typename range_difference<const Rng>::type difference_type;
|
||||
|
||||
return strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
bidirectional_traversal_tag
|
||||
>(boost::begin(rng), difference_type(), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
bidirectional_traversal_tag
|
||||
>
|
||||
make_end_strided_iterator(
|
||||
Rng& rng,
|
||||
Difference stride,
|
||||
bidirectional_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
bidirectional_traversal_tag
|
||||
>(boost::end(rng), boost::size(rng), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
bidirectional_traversal_tag
|
||||
>
|
||||
make_end_strided_iterator(
|
||||
const Rng& rng,
|
||||
Difference stride,
|
||||
bidirectional_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
bidirectional_traversal_tag
|
||||
>(boost::end(rng), boost::size(rng), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
random_access_traversal_tag
|
||||
>
|
||||
make_begin_strided_iterator(
|
||||
Rng& rng,
|
||||
Difference stride,
|
||||
random_access_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
random_access_traversal_tag
|
||||
>(boost::begin(rng), boost::begin(rng), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
random_access_traversal_tag
|
||||
>
|
||||
make_begin_strided_iterator(
|
||||
const Rng& rng,
|
||||
Difference stride,
|
||||
random_access_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
random_access_traversal_tag
|
||||
>(boost::begin(rng), boost::begin(rng), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
random_access_traversal_tag
|
||||
>
|
||||
make_end_strided_iterator(
|
||||
Rng& rng,
|
||||
Difference stride,
|
||||
random_access_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
random_access_traversal_tag
|
||||
>(boost::begin(rng), boost::end(rng), stride);
|
||||
}
|
||||
|
||||
template<class Rng, class Difference> inline
|
||||
strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
random_access_traversal_tag
|
||||
>
|
||||
make_end_strided_iterator(
|
||||
const Rng& rng,
|
||||
Difference stride,
|
||||
random_access_traversal_tag)
|
||||
{
|
||||
return strided_iterator<
|
||||
typename range_iterator<const Rng>::type,
|
||||
random_access_traversal_tag
|
||||
>(boost::begin(rng), boost::end(rng), stride);
|
||||
}
|
||||
|
||||
template<
|
||||
class Rng,
|
||||
class Category =
|
||||
typename iterator_traversal<
|
||||
typename range_iterator<Rng>::type
|
||||
>::type
|
||||
>
|
||||
class strided_range
|
||||
: public iterator_range<
|
||||
range_detail::strided_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type,
|
||||
Category
|
||||
>
|
||||
>
|
||||
range_detail::strided_iterator<
|
||||
typename range_iterator<Rng>::type,
|
||||
Category
|
||||
>
|
||||
>
|
||||
{
|
||||
typedef range_detail::strided_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type,
|
||||
Category
|
||||
> iter_type;
|
||||
typename range_iterator<Rng>::type,
|
||||
Category
|
||||
> iter_type;
|
||||
typedef iterator_range<iter_type> super_t;
|
||||
public:
|
||||
template<class Difference>
|
||||
strided_range(Difference stride, Rng& rng)
|
||||
: 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))
|
||||
: super_t(
|
||||
range_detail::make_begin_strided_iterator(
|
||||
rng, stride,
|
||||
typename iterator_traversal<
|
||||
typename range_iterator<Rng>::type
|
||||
>::type()),
|
||||
range_detail::make_end_strided_iterator(
|
||||
rng, stride,
|
||||
typename iterator_traversal<
|
||||
typename range_iterator<Rng>::type
|
||||
>::type()))
|
||||
{
|
||||
BOOST_ASSERT( stride >= 0 );
|
||||
}
|
||||
@ -300,7 +643,10 @@ namespace boost
|
||||
class strided_holder : public holder<Difference>
|
||||
{
|
||||
public:
|
||||
explicit strided_holder(Difference value) : holder<Difference>(value) {}
|
||||
explicit strided_holder(Difference value)
|
||||
: holder<Difference>(value)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<class Rng, class Difference>
|
||||
@ -327,7 +673,8 @@ namespace boost
|
||||
namespace
|
||||
{
|
||||
const range_detail::forwarder<range_detail::strided_holder>
|
||||
strided = range_detail::forwarder<range_detail::strided_holder>();
|
||||
strided = range_detail::forwarder<
|
||||
range_detail::strided_holder>();
|
||||
}
|
||||
|
||||
template<class Range, class Difference>
|
||||
|
@ -31,7 +31,7 @@ namespace boost
|
||||
IteratorCategoryTag1,
|
||||
IteratorCategoryTag2 )
|
||||
{
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
// If we have reached the end of the left range then this is
|
||||
// the end of the loop. They are equal if and only if we have
|
||||
@ -71,7 +71,7 @@ namespace boost
|
||||
IteratorCategoryTag1,
|
||||
IteratorCategoryTag2 )
|
||||
{
|
||||
while (true)
|
||||
for (;;)
|
||||
{
|
||||
// If we have reached the end of the left range then this is
|
||||
// the end of the loop. They are equal if and only if we have
|
||||
@ -120,7 +120,9 @@ namespace boost
|
||||
RandomAccessTraversalReadableIterator1 last1,
|
||||
RandomAccessTraversalReadableIterator2 first2,
|
||||
RandomAccessTraversalReadableIterator2 last2,
|
||||
BinaryPredicate pred )
|
||||
BinaryPredicate pred,
|
||||
std::random_access_iterator_tag,
|
||||
std::random_access_iterator_tag )
|
||||
{
|
||||
return ((last1 - first1) == (last2 - first2))
|
||||
&& std::equal(first1, last1, first2, pred);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost
|
||||
@ -27,8 +28,8 @@ inline Container& push_back( Container& on, const Range& from )
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
|
||||
BOOST_ASSERT( (void*)&on != (void*)&from &&
|
||||
"cannot copy from a container to itself" );
|
||||
BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from),
|
||||
"cannot copy from a container to itself");
|
||||
on.insert( on.end(), boost::begin(from), boost::end(from) );
|
||||
return on;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/detail/implementation_help.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
namespace boost
|
||||
@ -27,8 +28,8 @@ inline Container& push_front( Container& on, const Range& from )
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<Container> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const Range> ));
|
||||
BOOST_ASSERT( (void*)&on != (void*)&from &&
|
||||
"cannot copy from a container to itself" );
|
||||
BOOST_ASSERT_MSG(!range_detail::is_same_object(on, from),
|
||||
"cannot copy from a container to itself");
|
||||
on.insert( on.begin(), boost::begin(from), boost::end(from) );
|
||||
return on;
|
||||
}
|
||||
|
@ -17,11 +17,11 @@
|
||||
|
||||
#include <boost/range/iterator_range_core.hpp>
|
||||
#include <boost/range/value_type.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/iterator/counting_iterator.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
template<class Value>
|
||||
inline iterator_range<counting_iterator<Value> >
|
||||
counting_range(Value first, Value last)
|
||||
@ -33,29 +33,39 @@ namespace boost
|
||||
}
|
||||
|
||||
template<class Range>
|
||||
inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> >
|
||||
inline iterator_range<
|
||||
counting_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type
|
||||
>
|
||||
>
|
||||
counting_range(const Range& rng)
|
||||
{
|
||||
typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<const Range>::type> counting_iterator_t;
|
||||
typedef counting_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<const Range>::type
|
||||
> counting_iterator_t;
|
||||
|
||||
typedef iterator_range<counting_iterator_t> result_t;
|
||||
return boost::empty(rng)
|
||||
? result_t()
|
||||
: result_t(
|
||||
counting_iterator_t(*boost::begin(rng)),
|
||||
counting_iterator_t(*boost::prior(boost::end(rng))));
|
||||
|
||||
return result_t(counting_iterator_t(boost::begin(rng)),
|
||||
counting_iterator_t(boost::end(rng)));
|
||||
}
|
||||
|
||||
template<class Range>
|
||||
inline iterator_range<counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> >
|
||||
inline iterator_range<
|
||||
counting_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
|
||||
>
|
||||
>
|
||||
counting_range(Range& rng)
|
||||
{
|
||||
typedef counting_iterator<BOOST_DEDUCED_TYPENAME range_value<Range>::type> counting_iterator_t;
|
||||
typedef counting_iterator<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<Range>::type
|
||||
> counting_iterator_t;
|
||||
|
||||
typedef iterator_range<counting_iterator_t> result_t;
|
||||
return boost::empty(rng)
|
||||
? result_t()
|
||||
: result_t(
|
||||
counting_iterator_t(*boost::begin(rng)),
|
||||
counting_iterator_t(*boost::prior(boost::end(rng))));
|
||||
|
||||
return result_t(counting_iterator_t(boost::begin(rng)),
|
||||
counting_iterator_t(boost::end(rng)));
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
|
@ -27,25 +27,40 @@ namespace boost
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
typename is_reference<T>::type,
|
||||
typename add_reference<
|
||||
typename add_const<
|
||||
typename remove_reference<T>::type
|
||||
>::type
|
||||
>::type,
|
||||
typename add_const<
|
||||
typename remove_reference<T>::type
|
||||
>::type&,
|
||||
T
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct mutable_reference_type_generator
|
||||
{
|
||||
typedef typename mpl::if_<
|
||||
typename mpl::and_<
|
||||
typename is_const<T>::type,
|
||||
typename mpl::not_<typename is_reference<T>::type>::type
|
||||
>::type,
|
||||
T,
|
||||
typename add_reference<T>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<
|
||||
class Reference
|
||||
, class Buffer
|
||||
>
|
||||
struct any_incrementable_iterator_interface
|
||||
{
|
||||
typedef Reference reference;
|
||||
typedef typename mutable_reference_type_generator<
|
||||
Reference
|
||||
>::type 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;
|
||||
@ -87,7 +102,7 @@ namespace boost
|
||||
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 reference dereference() const = 0;
|
||||
|
||||
virtual bool equal(const any_single_pass_iterator_interface& other) const = 0;
|
||||
};
|
||||
|
@ -19,6 +19,17 @@ namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
template<class Reference, class T>
|
||||
Reference dereference_cast(T& x)
|
||||
{
|
||||
return static_cast<Reference>(x);
|
||||
}
|
||||
template<class Reference, class T>
|
||||
Reference dereference_cast(const T& x)
|
||||
{
|
||||
return static_cast<Reference>(const_cast<T&>(x));
|
||||
}
|
||||
|
||||
template<
|
||||
class WrappedIterator
|
||||
, class Reference
|
||||
@ -114,7 +125,13 @@ namespace boost
|
||||
{
|
||||
struct disabler {};
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassIteratorConcept<WrappedIterator> ));
|
||||
typedef any_single_pass_iterator_interface<
|
||||
Reference,
|
||||
Buffer
|
||||
> base_type;
|
||||
|
||||
public:
|
||||
typedef typename base_type::reference reference;
|
||||
|
||||
any_single_pass_iterator_wrapper()
|
||||
: m_it()
|
||||
@ -178,9 +195,9 @@ namespace boost
|
||||
return m_it == boost::polymorphic_downcast<const any_single_pass_iterator_wrapper*>(&other)->m_it;
|
||||
}
|
||||
|
||||
virtual Reference dereference() const
|
||||
virtual reference dereference() const
|
||||
{
|
||||
return *m_it;
|
||||
return dereference_cast<reference>(*m_it);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -199,7 +216,14 @@ namespace boost
|
||||
>
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( ForwardIteratorConcept<WrappedIterator> ));
|
||||
typedef any_forward_iterator_interface<
|
||||
Reference,
|
||||
Buffer
|
||||
> base_type;
|
||||
|
||||
public:
|
||||
typedef typename base_type::reference reference;
|
||||
|
||||
any_forward_iterator_wrapper()
|
||||
: m_it()
|
||||
{}
|
||||
@ -263,9 +287,9 @@ namespace boost
|
||||
return m_it == boost::polymorphic_downcast<const any_forward_iterator_wrapper*>(&other)->m_it;
|
||||
}
|
||||
|
||||
virtual Reference dereference() const
|
||||
virtual reference dereference() const
|
||||
{
|
||||
return *m_it;
|
||||
return dereference_cast<reference>(*m_it);
|
||||
}
|
||||
private:
|
||||
WrappedIterator m_it;
|
||||
@ -283,7 +307,14 @@ namespace boost
|
||||
>
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( BidirectionalIteratorConcept<WrappedIterator> ));
|
||||
typedef any_bidirectional_iterator_interface<
|
||||
Reference,
|
||||
Buffer
|
||||
> base_type;
|
||||
|
||||
public:
|
||||
typedef typename base_type::reference reference;
|
||||
|
||||
any_bidirectional_iterator_wrapper()
|
||||
: m_it()
|
||||
{
|
||||
@ -353,9 +384,9 @@ namespace boost
|
||||
return m_it == boost::polymorphic_downcast<const any_bidirectional_iterator_wrapper*>(&other)->m_it;
|
||||
}
|
||||
|
||||
virtual Reference dereference() const
|
||||
virtual reference dereference() const
|
||||
{
|
||||
return *m_it;
|
||||
return dereference_cast<reference>(*m_it);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -376,7 +407,14 @@ namespace boost
|
||||
>
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( RandomAccessIteratorConcept<WrappedIterator> ));
|
||||
typedef any_random_access_iterator_interface<
|
||||
Reference,
|
||||
Difference,
|
||||
Buffer
|
||||
> base_type;
|
||||
|
||||
public:
|
||||
typedef typename base_type::reference reference;
|
||||
typedef Difference difference_type;
|
||||
|
||||
any_random_access_iterator_wrapper()
|
||||
@ -457,9 +495,9 @@ namespace boost
|
||||
m_it += offset;
|
||||
}
|
||||
|
||||
virtual Reference dereference() const
|
||||
virtual reference dereference() const
|
||||
{
|
||||
return *m_it;
|
||||
return dereference_cast<reference>(*m_it);
|
||||
}
|
||||
|
||||
virtual Difference distance_to(const any_random_access_iterator_interface<Reference, Difference, Buffer>& other) const
|
||||
|
66
include/boost/range/detail/has_member_size.hpp
Normal file
66
include/boost/range/detail/has_member_size.hpp
Normal file
@ -0,0 +1,66 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Neil Groves 2014.
|
||||
//
|
||||
// Use, modification and distribution are 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_HAS_MEMBER_SIZE_HPP
|
||||
#define BOOST_RANGE_DETAIL_HAS_MEMBER_SIZE_HPP
|
||||
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/is_member_function_pointer.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
|
||||
template<class T>
|
||||
class has_member_size_impl
|
||||
{
|
||||
private:
|
||||
template<class U, U>
|
||||
class check
|
||||
{
|
||||
};
|
||||
|
||||
template<class C>
|
||||
static boost::uint8_t f(check<std::size_t(C::*)(void) const, &C::size>*);
|
||||
|
||||
template<class C>
|
||||
static boost::uint16_t f(...);
|
||||
|
||||
public:
|
||||
static const bool value =
|
||||
(sizeof(f<T>(0)) == sizeof(boost::uint8_t));
|
||||
|
||||
typedef typename mpl::if_c<
|
||||
(sizeof(f<T>(0)) == sizeof(boost::uint8_t)),
|
||||
mpl::true_,
|
||||
mpl::false_
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct has_member_size
|
||||
{
|
||||
typedef typename mpl::and_<
|
||||
typename is_class<T>::type,
|
||||
typename has_member_size_impl<const T>::type
|
||||
>::type type;
|
||||
|
||||
static const bool value =
|
||||
is_class<T>::value && has_member_size_impl<const T>::value;
|
||||
};
|
||||
|
||||
} // namespace range_detail
|
||||
}// namespace boost
|
||||
|
||||
#endif // include guard
|
@ -95,6 +95,17 @@ namespace boost
|
||||
return sz;
|
||||
}
|
||||
|
||||
inline bool is_same_address(const void* l, const void* r)
|
||||
{
|
||||
return l == r;
|
||||
}
|
||||
|
||||
template<class T1, class T2>
|
||||
inline bool is_same_object(const T1& l, const T2& r)
|
||||
{
|
||||
return range_detail::is_same_address(&l, &r);
|
||||
}
|
||||
|
||||
} // namespace 'range_detail'
|
||||
|
||||
} // namespace 'boost'
|
||||
|
@ -9,6 +9,9 @@
|
||||
// aschoedl contributed an improvement to the determination
|
||||
// of the Reference type parameter.
|
||||
//
|
||||
// Leonid Gershanovich reported Trac ticket 7376 about the dereference operator
|
||||
// requiring identical reference types due to using the ternary if.
|
||||
//
|
||||
// For more information, see http://www.boost.org/libs/range/
|
||||
//
|
||||
#ifndef BOOST_RANGE_DETAIL_JOIN_ITERATOR_HPP_INCLUDED
|
||||
@ -117,7 +120,8 @@ public:
|
||||
return *m_it;
|
||||
}
|
||||
|
||||
bool equal(const join_iterator_union& other, unsigned int selected) const
|
||||
bool equal(const join_iterator_union& other,
|
||||
unsigned int /*selected*/) const
|
||||
{
|
||||
return m_it == other.m_it;
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ namespace boost
|
||||
typedef typename base_t::value_type value_type;
|
||||
typedef typename base_t::difference_type difference_type;
|
||||
typedef typename base_t::reference reference;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
|
||||
integer_iterator() : m_value() {}
|
||||
explicit integer_iterator(value_type x) : m_value(x) {}
|
||||
@ -73,7 +74,11 @@ namespace boost
|
||||
|
||||
difference_type distance_to(const integer_iterator& other) const
|
||||
{
|
||||
return other.m_value - m_value;
|
||||
return is_signed<value_type>::value
|
||||
? (other.m_value - m_value)
|
||||
: (other.m_value >= m_value)
|
||||
? static_cast<difference_type>(other.m_value - m_value)
|
||||
: -static_cast<difference_type>(m_value - other.m_value);
|
||||
}
|
||||
|
||||
bool equal(const integer_iterator& other) const
|
||||
@ -123,6 +128,7 @@ namespace boost
|
||||
typedef typename base_t::value_type value_type;
|
||||
typedef typename base_t::difference_type difference_type;
|
||||
typedef typename base_t::reference reference;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
|
||||
integer_iterator_with_step(value_type first, difference_type step, value_type step_size)
|
||||
: m_first(first)
|
||||
@ -164,7 +170,7 @@ namespace boost
|
||||
|
||||
friend class ::boost::iterator_core_access;
|
||||
value_type m_first;
|
||||
value_type m_step;
|
||||
difference_type m_step;
|
||||
difference_type m_step_size;
|
||||
};
|
||||
|
||||
|
@ -25,46 +25,46 @@
|
||||
namespace boost
|
||||
{
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
namespace range_detail_vc7_1
|
||||
{
|
||||
template< typename C, typename Sig = void(C) >
|
||||
struct range_iterator
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
};
|
||||
|
||||
template< typename C, typename T >
|
||||
struct range_iterator< C, void(T[]) >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
namespace range_detail_vc7_1
|
||||
{
|
||||
template< typename C, typename Sig = void(C) >
|
||||
struct range_iterator
|
||||
{
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
};
|
||||
|
||||
template< typename C, typename T >
|
||||
struct range_iterator< C, void(T[]) >
|
||||
{
|
||||
typedef T* type;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
template< typename C >
|
||||
struct range_iterator
|
||||
{
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail_vc7_1::range_iterator<C>::type type;
|
||||
|
||||
#else
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
range_detail_vc7_1::range_iterator<C>::type type;
|
||||
|
||||
#else
|
||||
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
typedef BOOST_RANGE_DEDUCED_TYPENAME
|
||||
mpl::eval_if_c< is_const<C>::value,
|
||||
range_const_iterator< typename remove_const<C>::type >,
|
||||
range_mutable_iterator<C> >::type type;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
@ -24,10 +24,13 @@
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/type_traits/is_abstract.hpp>
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/iterator.hpp>
|
||||
#include <boost/range/difference_type.hpp>
|
||||
#include <boost/range/has_range_iterator.hpp>
|
||||
#include <boost/range/algorithm/equal.hpp>
|
||||
#include <boost/range/detail/safe_bool.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
@ -77,7 +80,7 @@ namespace boost
|
||||
template< class Left, class Right >
|
||||
inline bool greater_than( const Left& l, const Right& r )
|
||||
{
|
||||
return less_than(r,l);
|
||||
return iterator_range_detail::less_than(r,l);
|
||||
}
|
||||
|
||||
template< class Left, class Right >
|
||||
@ -100,8 +103,251 @@ namespace boost
|
||||
return boost::equal(l, r);
|
||||
}
|
||||
|
||||
struct range_tag { };
|
||||
struct const_range_tag { };
|
||||
struct range_tag
|
||||
{
|
||||
};
|
||||
|
||||
struct const_range_tag
|
||||
{
|
||||
};
|
||||
|
||||
struct iterator_range_tag
|
||||
{
|
||||
};
|
||||
|
||||
template<class IteratorT, class TraversalTag>
|
||||
class iterator_range_base
|
||||
: public iterator_range_tag
|
||||
{
|
||||
typedef range_detail::safe_bool<
|
||||
IteratorT iterator_range_base<IteratorT, TraversalTag>::*
|
||||
> safe_bool_t;
|
||||
|
||||
typedef iterator_range_base<IteratorT, TraversalTag> type;
|
||||
|
||||
protected:
|
||||
typedef iterator_range_impl<IteratorT> impl;
|
||||
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
safe_bool_t::unspecified_bool_type unspecified_bool_type;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<IteratorT>::type value_type;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_difference<IteratorT>::type difference_type;
|
||||
|
||||
typedef std::size_t size_type; // note: must be unsigned
|
||||
|
||||
// Needed because value-type is the same for
|
||||
// const and non-const iterators
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_reference<IteratorT>::type reference;
|
||||
|
||||
//! const_iterator type
|
||||
/*!
|
||||
There is no distinction between const_iterator and iterator.
|
||||
These typedefs are provides to fulfill container interface
|
||||
*/
|
||||
typedef IteratorT const_iterator;
|
||||
//! iterator type
|
||||
typedef IteratorT iterator;
|
||||
|
||||
protected:
|
||||
iterator_range_base()
|
||||
: m_Begin()
|
||||
, m_End()
|
||||
{
|
||||
}
|
||||
|
||||
template<class Iterator>
|
||||
iterator_range_base(Iterator Begin, Iterator End)
|
||||
: m_Begin(Begin)
|
||||
, m_End(End)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
IteratorT begin() const
|
||||
{
|
||||
return m_Begin;
|
||||
}
|
||||
|
||||
IteratorT end() const
|
||||
{
|
||||
return m_End;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return m_Begin == m_End;
|
||||
}
|
||||
|
||||
operator unspecified_bool_type() const
|
||||
{
|
||||
return safe_bool_t::to_unspecified_bool(
|
||||
m_Begin != m_End, &iterator_range_base::m_Begin);
|
||||
}
|
||||
|
||||
bool operator!() const
|
||||
{
|
||||
return empty();
|
||||
}
|
||||
|
||||
bool equal(const iterator_range_base& r) const
|
||||
{
|
||||
return m_Begin == r.m_Begin && m_End == r.m_End;
|
||||
}
|
||||
|
||||
reference front() const
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
return *m_Begin;
|
||||
}
|
||||
|
||||
void pop_front()
|
||||
{
|
||||
BOOST_ASSERT(!empty());
|
||||
++m_Begin;
|
||||
}
|
||||
|
||||
protected:
|
||||
template<class Iterator>
|
||||
void assign(Iterator first, Iterator last)
|
||||
{
|
||||
m_Begin = first;
|
||||
m_End = last;
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
void assign(const SinglePassRange& r)
|
||||
{
|
||||
m_Begin = impl::adl_begin(r);
|
||||
m_End = impl::adl_end(r);
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
void assign(SinglePassRange& r)
|
||||
{
|
||||
m_Begin = impl::adl_begin(r);
|
||||
m_End = impl::adl_end(r);
|
||||
}
|
||||
|
||||
IteratorT m_Begin;
|
||||
IteratorT m_End;
|
||||
};
|
||||
|
||||
template<class IteratorT>
|
||||
class iterator_range_base<IteratorT, bidirectional_traversal_tag>
|
||||
: public iterator_range_base<IteratorT, forward_traversal_tag>
|
||||
{
|
||||
typedef iterator_range_base<IteratorT, forward_traversal_tag> base_type;
|
||||
|
||||
protected:
|
||||
iterator_range_base()
|
||||
{
|
||||
}
|
||||
|
||||
template<class Iterator>
|
||||
iterator_range_base(Iterator first, Iterator last)
|
||||
: iterator_range_base<IteratorT, forward_traversal_tag>(first, last)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
BOOST_DEDUCED_TYPENAME base_type::reference back() const
|
||||
{
|
||||
BOOST_ASSERT(!this->empty());
|
||||
return *boost::prior(this->m_End);
|
||||
}
|
||||
|
||||
void pop_back()
|
||||
{
|
||||
BOOST_ASSERT(!this->empty());
|
||||
--this->m_End;
|
||||
}
|
||||
};
|
||||
|
||||
template<class IteratorT>
|
||||
class iterator_range_base<IteratorT, random_access_traversal_tag>
|
||||
: public iterator_range_base<IteratorT, bidirectional_traversal_tag>
|
||||
{
|
||||
typedef iterator_range_base<
|
||||
IteratorT, bidirectional_traversal_tag> base_type;
|
||||
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::mpl::if_<
|
||||
boost::mpl::or_<
|
||||
boost::is_abstract<
|
||||
BOOST_DEDUCED_TYPENAME base_type::value_type
|
||||
>,
|
||||
boost::is_array<
|
||||
BOOST_DEDUCED_TYPENAME base_type::value_type
|
||||
>
|
||||
>,
|
||||
BOOST_DEDUCED_TYPENAME base_type::reference,
|
||||
BOOST_DEDUCED_TYPENAME base_type::value_type
|
||||
>::type abstract_value_type;
|
||||
|
||||
// Rationale:
|
||||
// typedef these here to reduce verbiage in the implementation of this
|
||||
// type.
|
||||
typedef BOOST_DEDUCED_TYPENAME base_type::difference_type difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME base_type::size_type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME base_type::reference reference;
|
||||
|
||||
protected:
|
||||
iterator_range_base()
|
||||
{
|
||||
}
|
||||
|
||||
template<class Iterator>
|
||||
iterator_range_base(Iterator first, Iterator last)
|
||||
: iterator_range_base<IteratorT, bidirectional_traversal_tag>(
|
||||
first, last)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
reference operator[](difference_type at) const
|
||||
{
|
||||
BOOST_ASSERT(at >= 0 && at < size());
|
||||
return this->m_Begin[at];
|
||||
}
|
||||
|
||||
//
|
||||
// When storing transform iterators, operator[]()
|
||||
// fails because it returns by reference. Therefore
|
||||
// operator()() is provided for these cases.
|
||||
//
|
||||
abstract_value_type operator()(difference_type at) const
|
||||
{
|
||||
BOOST_ASSERT(at >= 0 && at < size());
|
||||
return this->m_Begin[at];
|
||||
}
|
||||
|
||||
void pop_front(difference_type n)
|
||||
{
|
||||
BOOST_ASSERT(n >= difference_type());
|
||||
BOOST_ASSERT(size() >= static_cast<size_type>(n));
|
||||
std::advance(this->m_Begin, n);
|
||||
}
|
||||
|
||||
void pop_back(difference_type n)
|
||||
{
|
||||
BOOST_ASSERT(n >= difference_type());
|
||||
BOOST_ASSERT(size() >= static_cast<size_type>(n));
|
||||
std::advance(this->m_End, -n);
|
||||
}
|
||||
|
||||
BOOST_DEDUCED_TYPENAME base_type::size_type size() const
|
||||
{
|
||||
return this->m_End - this->m_Begin;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// iterator range template class -----------------------------------------//
|
||||
@ -125,251 +371,109 @@ namespace boost
|
||||
*/
|
||||
template<class IteratorT>
|
||||
class iterator_range
|
||||
: public iterator_range_detail::iterator_range_base<
|
||||
IteratorT,
|
||||
BOOST_DEDUCED_TYPENAME iterator_traversal<IteratorT>::type
|
||||
>
|
||||
{
|
||||
typedef range_detail::safe_bool< IteratorT iterator_range<IteratorT>::* > safe_bool_t;
|
||||
protected: // Used by sub_range
|
||||
//! implementation class
|
||||
typedef iterator_range_detail::iterator_range_base<
|
||||
IteratorT,
|
||||
BOOST_DEDUCED_TYPENAME iterator_traversal<IteratorT>::type
|
||||
> base_type;
|
||||
|
||||
template<class Source>
|
||||
struct is_compatible_range
|
||||
: is_convertible<
|
||||
BOOST_DEDUCED_TYPENAME mpl::eval_if<
|
||||
has_range_iterator<Source>,
|
||||
range_iterator<Source>,
|
||||
mpl::identity<void>
|
||||
>::type,
|
||||
BOOST_DEDUCED_TYPENAME base_type::iterator
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
protected:
|
||||
typedef iterator_range_detail::iterator_range_impl<IteratorT> impl;
|
||||
|
||||
public:
|
||||
//! this type
|
||||
typedef iterator_range<IteratorT> type;
|
||||
typedef BOOST_DEDUCED_TYPENAME safe_bool_t::unspecified_bool_type unspecified_bool_type;
|
||||
//BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(value_type);
|
||||
|
||||
//! Encapsulated value type
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_value<IteratorT>::type value_type;
|
||||
|
||||
//! Difference type
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_difference<IteratorT>::type difference_type;
|
||||
|
||||
//! Size type
|
||||
typedef std::size_t size_type; // note: must be unsigned
|
||||
|
||||
//! This type
|
||||
typedef iterator_range<IteratorT> this_type;
|
||||
|
||||
//! Reference type
|
||||
//
|
||||
// Needed because value-type is the same for
|
||||
// const and non-const iterators
|
||||
//
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
iterator_reference<IteratorT>::type reference;
|
||||
|
||||
//! const_iterator type
|
||||
/*!
|
||||
There is no distinction between const_iterator and iterator.
|
||||
These typedefs are provides to fulfill container interface
|
||||
*/
|
||||
typedef IteratorT const_iterator;
|
||||
//! iterator type
|
||||
typedef IteratorT iterator;
|
||||
|
||||
private: // for return value of operator()()
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::mpl::if_< boost::mpl::or_< boost::is_abstract< value_type >,
|
||||
boost::is_array< value_type > >,
|
||||
reference, value_type >::type abstract_value_type;
|
||||
|
||||
public:
|
||||
iterator_range() : m_Begin( iterator() ), m_End( iterator() )
|
||||
{ }
|
||||
|
||||
//! Constructor from a pair of iterators
|
||||
template< class Iterator >
|
||||
iterator_range( Iterator Begin, Iterator End ) :
|
||||
m_Begin(Begin), m_End(End)
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( const Range& r ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( Range& r ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( const Range& r, iterator_range_detail::const_range_tag ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
{}
|
||||
|
||||
//! Constructor from a Range
|
||||
template< class Range >
|
||||
iterator_range( Range& r, iterator_range_detail::range_tag ) :
|
||||
m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
|
||||
{}
|
||||
|
||||
this_type& operator=( const this_type& r )
|
||||
iterator_range()
|
||||
{
|
||||
m_Begin = r.begin();
|
||||
m_End = r.end();
|
||||
}
|
||||
|
||||
template<class Iterator>
|
||||
iterator_range(Iterator first, Iterator last)
|
||||
: base_type(first, last)
|
||||
{
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
iterator_range(
|
||||
const SinglePassRange& r,
|
||||
BOOST_DEDUCED_TYPENAME enable_if<
|
||||
is_compatible_range<const SinglePassRange>
|
||||
>::type* = 0
|
||||
)
|
||||
: base_type(impl::adl_begin(r), impl::adl_end(r))
|
||||
{
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
iterator_range(
|
||||
SinglePassRange& r,
|
||||
BOOST_DEDUCED_TYPENAME enable_if<
|
||||
is_compatible_range<SinglePassRange>
|
||||
>::type* = 0
|
||||
)
|
||||
: base_type(impl::adl_begin(r), impl::adl_end(r))
|
||||
{
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
iterator_range(const SinglePassRange& r,
|
||||
iterator_range_detail::const_range_tag)
|
||||
: base_type(impl::adl_begin(r), impl::adl_end(r))
|
||||
{
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
iterator_range(SinglePassRange& r,
|
||||
iterator_range_detail::range_tag)
|
||||
: base_type(impl::adl_begin(r), impl::adl_end(r))
|
||||
{
|
||||
}
|
||||
|
||||
template<class Iterator>
|
||||
iterator_range& operator=(const iterator_range<Iterator>& other)
|
||||
{
|
||||
this->assign(other.begin(), other.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class Iterator >
|
||||
iterator_range& operator=( const iterator_range<Iterator>& r )
|
||||
template<class Iterator>
|
||||
iterator_range& operator=(iterator_range<Iterator>& other)
|
||||
{
|
||||
m_Begin = r.begin();
|
||||
m_End = r.end();
|
||||
this->assign(other.begin(), other.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
iterator_range& operator=( ForwardRange& r )
|
||||
template<class SinglePassRange>
|
||||
iterator_range& operator=(SinglePassRange& r)
|
||||
{
|
||||
m_Begin = impl::adl_begin( r );
|
||||
m_End = impl::adl_end( r );
|
||||
this->assign(r);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class ForwardRange >
|
||||
iterator_range& operator=( const ForwardRange& r )
|
||||
template<class SinglePassRange>
|
||||
iterator_range& operator=(const SinglePassRange& r)
|
||||
{
|
||||
m_Begin = impl::adl_begin( r );
|
||||
m_End = impl::adl_end( r );
|
||||
this->assign(r);
|
||||
return *this;
|
||||
}
|
||||
|
||||
IteratorT begin() const
|
||||
{
|
||||
return m_Begin;
|
||||
}
|
||||
|
||||
IteratorT end() const
|
||||
{
|
||||
return m_End;
|
||||
}
|
||||
|
||||
difference_type size() const
|
||||
{
|
||||
return m_End - m_Begin;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return m_Begin == m_End;
|
||||
}
|
||||
|
||||
operator unspecified_bool_type() const
|
||||
{
|
||||
return safe_bool_t::to_unspecified_bool(m_Begin != m_End, &iterator_range::m_Begin);
|
||||
}
|
||||
|
||||
bool operator!() const
|
||||
{
|
||||
return empty();
|
||||
}
|
||||
|
||||
bool equal( const iterator_range& r ) const
|
||||
{
|
||||
return m_Begin == r.m_Begin && m_End == r.m_End;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
bool operator==( const iterator_range& r ) const
|
||||
{
|
||||
return boost::equal( *this, r );
|
||||
}
|
||||
|
||||
bool operator!=( const iterator_range& r ) const
|
||||
{
|
||||
return !operator==(r);
|
||||
}
|
||||
|
||||
bool operator<( const iterator_range& r ) const
|
||||
{
|
||||
return iterator_range_detail::less_than( *this, r );
|
||||
}
|
||||
|
||||
bool operator>( const iterator_range& r ) const
|
||||
{
|
||||
return iterator_range_detail::greater_than( *this, r );
|
||||
}
|
||||
|
||||
bool operator<=( const iterator_range& r ) const
|
||||
{
|
||||
return iterator_range_detail::less_or_equal_than( *this, r );
|
||||
}
|
||||
|
||||
bool operator>=( const iterator_range& r ) const
|
||||
{
|
||||
return iterator_range_detail::greater_or_equal_than( *this, r );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public: // convenience
|
||||
reference front() const
|
||||
{
|
||||
BOOST_ASSERT( !empty() );
|
||||
return *m_Begin;
|
||||
}
|
||||
|
||||
reference back() const
|
||||
{
|
||||
BOOST_ASSERT( !empty() );
|
||||
IteratorT last( m_End );
|
||||
return *--last;
|
||||
}
|
||||
|
||||
// pop_front() - added to model the SinglePassRangePrimitiveConcept
|
||||
void pop_front()
|
||||
{
|
||||
BOOST_ASSERT( !empty() );
|
||||
++m_Begin;
|
||||
}
|
||||
|
||||
// pop_back() - added to model the BidirectionalRangePrimitiveConcept
|
||||
void pop_back()
|
||||
{
|
||||
BOOST_ASSERT( !empty() );
|
||||
--m_End;
|
||||
}
|
||||
|
||||
reference operator[]( difference_type at ) const
|
||||
{
|
||||
BOOST_ASSERT( at >= 0 && at < size() );
|
||||
return m_Begin[at];
|
||||
}
|
||||
|
||||
//
|
||||
// When storing transform iterators, operator[]()
|
||||
// fails because it returns by reference. Therefore
|
||||
// operator()() is provided for these cases.
|
||||
//
|
||||
abstract_value_type operator()( difference_type at ) const
|
||||
{
|
||||
BOOST_ASSERT( at >= 0 && at < size() );
|
||||
return m_Begin[at];
|
||||
}
|
||||
|
||||
iterator_range& advance_begin( difference_type n )
|
||||
{
|
||||
std::advance( m_Begin, n );
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator_range& advance_end( difference_type n )
|
||||
{
|
||||
std::advance( m_End, n );
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
// begin and end iterators
|
||||
IteratorT m_Begin;
|
||||
IteratorT m_End;
|
||||
|
||||
protected:
|
||||
//
|
||||
// Allow subclasses an easy way to access the
|
||||
@ -383,138 +487,143 @@ namespace boost
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// comparison operators
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator==( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline BOOST_DEDUCED_TYPENAME enable_if<
|
||||
mpl::or_<
|
||||
is_convertible<
|
||||
const SinglePassRange1&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>,
|
||||
is_convertible<
|
||||
const SinglePassRange2&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>
|
||||
>,
|
||||
bool
|
||||
>::type
|
||||
operator==(const SinglePassRange1& l, const SinglePassRange2& r)
|
||||
{
|
||||
return boost::equal( l, r );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange1>));
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange2>));
|
||||
return boost::equal(l, r);
|
||||
}
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline BOOST_DEDUCED_TYPENAME enable_if<
|
||||
mpl::or_<
|
||||
is_convertible<
|
||||
const SinglePassRange1&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>,
|
||||
is_convertible<
|
||||
const SinglePassRange2&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>
|
||||
>,
|
||||
bool
|
||||
>::type
|
||||
operator!=(const SinglePassRange1& l, const SinglePassRange2& r)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange1>));
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange2>));
|
||||
return !boost::equal(l, r);
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator!=( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline BOOST_DEDUCED_TYPENAME enable_if<
|
||||
mpl::or_<
|
||||
is_convertible<
|
||||
const SinglePassRange1&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>,
|
||||
is_convertible<
|
||||
const SinglePassRange2&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>
|
||||
>,
|
||||
bool
|
||||
>::type
|
||||
operator<(const SinglePassRange1& l, const SinglePassRange2& r)
|
||||
{
|
||||
return !boost::equal( l, r );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange1>));
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange2>));
|
||||
return iterator_range_detail::less_than(l, r);
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator<( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline BOOST_DEDUCED_TYPENAME enable_if<
|
||||
mpl::or_<
|
||||
is_convertible<
|
||||
const SinglePassRange1&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>,
|
||||
is_convertible<
|
||||
const SinglePassRange2&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>
|
||||
>,
|
||||
bool
|
||||
>::type
|
||||
operator<=(const SinglePassRange1& l, const SinglePassRange2& r)
|
||||
{
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange1>));
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange2>));
|
||||
return iterator_range_detail::less_or_equal_than(l, r);
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator<=( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline BOOST_DEDUCED_TYPENAME enable_if<
|
||||
mpl::or_<
|
||||
is_convertible<
|
||||
const SinglePassRange1&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>,
|
||||
is_convertible<
|
||||
const SinglePassRange2&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>
|
||||
>,
|
||||
bool
|
||||
>::type
|
||||
operator>(const SinglePassRange1& l, const SinglePassRange2& r)
|
||||
{
|
||||
return iterator_range_detail::less_or_equal_than( l, r );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange1>));
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange2>));
|
||||
return iterator_range_detail::greater_than(l, r);
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator>( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline BOOST_DEDUCED_TYPENAME enable_if<
|
||||
mpl::or_<
|
||||
is_convertible<
|
||||
const SinglePassRange1&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>,
|
||||
is_convertible<
|
||||
const SinglePassRange2&,
|
||||
const iterator_range_detail::iterator_range_tag&
|
||||
>
|
||||
>,
|
||||
bool
|
||||
>::type
|
||||
operator>=(const SinglePassRange1& l, const SinglePassRange2& r)
|
||||
{
|
||||
return iterator_range_detail::greater_than( l, r );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange1>));
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
boost::SinglePassRangeConcept<const SinglePassRange2>));
|
||||
return iterator_range_detail::greater_or_equal_than(l, r);
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator>=( const ForwardRange& l,
|
||||
const iterator_range<IteratorT>& r )
|
||||
{
|
||||
return iterator_range_detail::greater_or_equal_than( l, r );
|
||||
}
|
||||
|
||||
#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
#else
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator==( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return boost::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator==( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return boost::equal( l, r );
|
||||
}
|
||||
|
||||
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator!=( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return !boost::equal( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator!=( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return !boost::equal( l, r );
|
||||
}
|
||||
|
||||
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator<( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator<( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator<=( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return iterator_range_detail::less_or_equal_than( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator<=( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return iterator_range_detail::less_or_equal_than( l, r );
|
||||
}
|
||||
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator>( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return iterator_range_detail::greater_than( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator>( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return iterator_range_detail::greater_than( l, r );
|
||||
}
|
||||
|
||||
template< class Iterator1T, class Iterator2T >
|
||||
inline bool operator>=( const iterator_range<Iterator1T>& l,
|
||||
const iterator_range<Iterator2T>& r )
|
||||
{
|
||||
return iterator_range_detail::greater_or_equal_than( l, r );
|
||||
}
|
||||
|
||||
template< class IteratorT, class ForwardRange >
|
||||
inline bool operator>=( const iterator_range<IteratorT>& l,
|
||||
const ForwardRange& r )
|
||||
{
|
||||
return iterator_range_detail::greater_or_equal_than( l, r );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||
|
||||
// iterator range utilities -----------------------------------------//
|
||||
|
||||
@ -599,7 +708,6 @@ namespace boost
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
@ -611,7 +719,6 @@ namespace boost
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
@ -621,7 +728,6 @@ namespace boost
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_begin,
|
||||
BOOST_DEDUCED_TYPENAME range_difference<Range>::type advance_end )
|
||||
{
|
||||
//BOOST_ASSERT( advance_begin - advance_end <= size(r) && "creating invalid range" );
|
||||
return iterator_range_detail::make_range_impl( r, advance_begin, advance_end );
|
||||
}
|
||||
|
||||
|
114
include/boost/range/mfc_map.hpp
Normal file
114
include/boost/range/mfc_map.hpp
Normal file
@ -0,0 +1,114 @@
|
||||
// Boost.Range library
|
||||
//
|
||||
// Copyright Adam D. Walling 2012. 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_MFC_MAP_HPP
|
||||
#define BOOST_RANGE_ADAPTOR_MFC_MAP_HPP
|
||||
|
||||
#if !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
|
||||
#include <boost/range/mfc.hpp>
|
||||
#include <boost/range/adaptor/map.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
// CMap and CMapStringToString range iterators return CPair,
|
||||
// which has a key and value member. Other MFC range iterators
|
||||
// already return adapted std::pair objects. This allows usage
|
||||
// of the map_keys and map_values range adaptors with CMap
|
||||
// and CMapStringToString
|
||||
|
||||
// CPair has a VALUE value member, and a KEY key member; we will
|
||||
// use VALUE& as the result_type consistent with CMap::operator[]
|
||||
|
||||
// specialization for CMap
|
||||
template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
|
||||
struct select_first< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reference<const map_type>::type argument_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME const KEY& result_type;
|
||||
|
||||
result_type operator()( argument_type r ) const
|
||||
{
|
||||
return r.key;
|
||||
}
|
||||
};
|
||||
|
||||
template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
|
||||
struct select_second_mutable< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reference<map_type>::type argument_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME VALUE& result_type;
|
||||
|
||||
result_type operator()( argument_type r ) const
|
||||
{
|
||||
return r.value;
|
||||
}
|
||||
};
|
||||
|
||||
template<class KEY, class ARG_KEY, class VALUE, class ARG_VALUE>
|
||||
struct select_second_const< CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> >
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME CMap<KEY, ARG_KEY, VALUE, ARG_VALUE> map_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_reference<const map_type>::type argument_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME const VALUE& result_type;
|
||||
|
||||
result_type operator()( argument_type r ) const
|
||||
{
|
||||
return r.value;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// specialization for CMapStringToString
|
||||
template<>
|
||||
struct select_first< CMapStringToString >
|
||||
{
|
||||
typedef range_reference<const CMapStringToString>::type argument_type;
|
||||
typedef const CString& result_type;
|
||||
|
||||
result_type operator()( argument_type r ) const
|
||||
{
|
||||
return r.key;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct select_second_mutable< CMapStringToString >
|
||||
{
|
||||
typedef range_reference<CMapStringToString>::type argument_type;
|
||||
typedef CString& result_type;
|
||||
|
||||
result_type operator()( argument_type r ) const
|
||||
{
|
||||
return r.value;
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct select_second_const< CMapStringToString >
|
||||
{
|
||||
typedef range_reference<const CMapStringToString>::type argument_type;
|
||||
typedef const CString& result_type;
|
||||
|
||||
result_type operator()( argument_type r ) const
|
||||
{
|
||||
return r.value;
|
||||
}
|
||||
};
|
||||
} // 'range_detail'
|
||||
} // 'boost'
|
||||
|
||||
#endif // !defined(BOOST_RANGE_MFC_NO_CPAIR)
|
||||
|
||||
#endif
|
@ -1,14 +1,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// \file algorithm.hpp
|
||||
/// Contains range-based versions of the std algorithms
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2009 Neil Groves.
|
||||
// Copyright 2009-2014 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)
|
||||
//
|
||||
|
||||
// Copyright 2006 Thorsten Ottosen.
|
||||
// Distributed under the Boost Software License, Version 1.0. (See
|
||||
// accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -18,7 +12,9 @@
|
||||
// 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)
|
||||
|
||||
//
|
||||
// Contains range-based versions of the numeric std algorithms
|
||||
//
|
||||
#if defined(_MSC_VER)
|
||||
#pragma once
|
||||
#endif
|
||||
@ -30,89 +26,163 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/category.hpp>
|
||||
#include <boost/range/concepts.hpp>
|
||||
#include <boost/range/distance.hpp>
|
||||
#include <boost/range/size.hpp>
|
||||
#include <numeric>
|
||||
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template< class SinglePassRange, class Value >
|
||||
inline Value accumulate( const SinglePassRange& rng, Value init )
|
||||
template<class SinglePassRange, class Value>
|
||||
inline Value accumulate(const SinglePassRange& rng, Value init)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
|
||||
return std::accumulate( boost::begin(rng), boost::end(rng), init );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange>));
|
||||
|
||||
return std::accumulate(boost::begin(rng), boost::end(rng), init);
|
||||
}
|
||||
|
||||
template< class SinglePassRange, class Value, class BinaryOperation >
|
||||
inline Value accumulate( const SinglePassRange& rng, Value init, BinaryOperation op )
|
||||
template<class SinglePassRange, class Value, class BinaryOperation>
|
||||
inline Value accumulate(const SinglePassRange& rng, Value init,
|
||||
BinaryOperation op)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
|
||||
return std::accumulate( boost::begin(rng), boost::end(rng), init, op );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange> ));
|
||||
|
||||
return std::accumulate(boost::begin(rng), boost::end(rng), init, op);
|
||||
}
|
||||
|
||||
|
||||
template< class SinglePassRange1, class SinglePassRange2, class Value >
|
||||
inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2, Value init )
|
||||
namespace range_detail
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
|
||||
BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) );
|
||||
return std::inner_product( boost::begin(rng1), boost::end(rng1),
|
||||
boost::begin(rng2), init );
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline bool inner_product_precondition(
|
||||
const SinglePassRange1&,
|
||||
const SinglePassRange2&,
|
||||
std::input_iterator_tag,
|
||||
std::input_iterator_tag)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class SinglePassRange1, class SinglePassRange2>
|
||||
inline bool inner_product_precondition(
|
||||
const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
std::forward_iterator_tag,
|
||||
std::forward_iterator_tag)
|
||||
{
|
||||
return boost::size(rng2) >= boost::size(rng1);
|
||||
}
|
||||
|
||||
} // namespace range_detail
|
||||
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class Value
|
||||
>
|
||||
inline Value inner_product(
|
||||
const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
Value init)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange1>));
|
||||
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange2>));
|
||||
|
||||
BOOST_ASSERT(
|
||||
range_detail::inner_product_precondition(
|
||||
rng1, rng2,
|
||||
typename range_category<const SinglePassRange1>::type(),
|
||||
typename range_category<const SinglePassRange2>::type()));
|
||||
|
||||
return std::inner_product(
|
||||
boost::begin(rng1), boost::end(rng1),
|
||||
boost::begin(rng2), init);
|
||||
}
|
||||
|
||||
template< class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class Value,
|
||||
class BinaryOperation1, class BinaryOperation2 >
|
||||
inline Value inner_product( const SinglePassRange1& rng1, const SinglePassRange2& rng2,
|
||||
Value init,
|
||||
BinaryOperation1 op1, BinaryOperation2 op2 )
|
||||
template<
|
||||
class SinglePassRange1,
|
||||
class SinglePassRange2,
|
||||
class Value,
|
||||
class BinaryOperation1,
|
||||
class BinaryOperation2
|
||||
>
|
||||
inline Value inner_product(
|
||||
const SinglePassRange1& rng1,
|
||||
const SinglePassRange2& rng2,
|
||||
Value init,
|
||||
BinaryOperation1 op1,
|
||||
BinaryOperation2 op2)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange1> ));
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange2> ));
|
||||
BOOST_ASSERT( boost::distance(rng2) >= boost::distance(rng1) );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange1>));
|
||||
|
||||
return std::inner_product( boost::begin(rng1), boost::end(rng1),
|
||||
boost::begin(rng2), init, op1, op2 );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange2>));
|
||||
|
||||
BOOST_ASSERT(
|
||||
range_detail::inner_product_precondition(
|
||||
rng1, rng2,
|
||||
typename range_category<const SinglePassRange1>::type(),
|
||||
typename range_category<const SinglePassRange2>::type()));
|
||||
|
||||
return std::inner_product(
|
||||
boost::begin(rng1), boost::end(rng1),
|
||||
boost::begin(rng2), init, op1, op2);
|
||||
}
|
||||
|
||||
template< class SinglePassRange, class OutputIterator >
|
||||
inline OutputIterator partial_sum ( const SinglePassRange& rng,
|
||||
OutputIterator result )
|
||||
template<class SinglePassRange, class OutputIterator>
|
||||
inline OutputIterator partial_sum(const SinglePassRange& rng,
|
||||
OutputIterator result)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
|
||||
return std::partial_sum( boost::begin(rng), boost::end(rng), result );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange>));
|
||||
|
||||
return std::partial_sum(boost::begin(rng), boost::end(rng), result);
|
||||
}
|
||||
|
||||
template< class SinglePassRange, class OutputIterator, class BinaryOperation >
|
||||
inline OutputIterator partial_sum ( const SinglePassRange& rng, OutputIterator result,
|
||||
BinaryOperation op )
|
||||
template<class SinglePassRange, class OutputIterator, class BinaryOperation>
|
||||
inline OutputIterator partial_sum(
|
||||
const SinglePassRange& rng,
|
||||
OutputIterator result,
|
||||
BinaryOperation op)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
|
||||
return std::partial_sum( boost::begin(rng), boost::end(rng), result, op );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange>));
|
||||
|
||||
return std::partial_sum(boost::begin(rng), boost::end(rng), result, op);
|
||||
}
|
||||
|
||||
template< class SinglePassRange, class OutputIterator >
|
||||
inline OutputIterator adjacent_difference ( const SinglePassRange& rng,
|
||||
OutputIterator result )
|
||||
template<class SinglePassRange, class OutputIterator>
|
||||
inline OutputIterator adjacent_difference(
|
||||
const SinglePassRange& rng,
|
||||
OutputIterator result)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<const SinglePassRange> ));
|
||||
return std::adjacent_difference( boost::begin(rng), boost::end(rng),
|
||||
result );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange>));
|
||||
|
||||
return std::adjacent_difference(boost::begin(rng), boost::end(rng),
|
||||
result);
|
||||
}
|
||||
|
||||
template< class SinglePassRange, class OutputIterator, class BinaryOperation >
|
||||
inline OutputIterator adjacent_difference ( const SinglePassRange& rng,
|
||||
OutputIterator result,
|
||||
BinaryOperation op )
|
||||
template<class SinglePassRange, class OutputIterator, class BinaryOperation>
|
||||
inline OutputIterator adjacent_difference(
|
||||
const SinglePassRange& rng,
|
||||
OutputIterator result,
|
||||
BinaryOperation op)
|
||||
{
|
||||
BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept<SinglePassRange> ));
|
||||
return std::adjacent_difference( boost::begin(rng), boost::end(rng),
|
||||
result, op );
|
||||
BOOST_RANGE_CONCEPT_ASSERT((
|
||||
SinglePassRangeConcept<const SinglePassRange>));
|
||||
|
||||
return std::adjacent_difference(boost::begin(rng), boost::end(rng),
|
||||
result, op);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
|
@ -19,24 +19,39 @@
|
||||
#include <boost/range/begin.hpp>
|
||||
#include <boost/range/end.hpp>
|
||||
#include <boost/range/size_type.hpp>
|
||||
#include <boost/range/detail/has_member_size.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace range_detail
|
||||
{
|
||||
|
||||
template<class SinglePassRange>
|
||||
inline BOOST_DEDUCED_TYPENAME range_size<const SinglePassRange>::type
|
||||
inline typename enable_if<
|
||||
has_member_size<SinglePassRange>,
|
||||
typename range_size<const SinglePassRange>::type
|
||||
>::type
|
||||
range_calculate_size(const SinglePassRange& rng)
|
||||
{
|
||||
BOOST_ASSERT( (boost::end(rng) - boost::begin(rng)) >= 0 &&
|
||||
"reachability invariant broken!" );
|
||||
return boost::end(rng) - boost::begin(rng);
|
||||
return rng.size();
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
inline typename disable_if<
|
||||
has_member_size<SinglePassRange>,
|
||||
typename range_size<const SinglePassRange>::type
|
||||
>::type
|
||||
range_calculate_size(const SinglePassRange& rng)
|
||||
{
|
||||
return std::distance(boost::begin(rng), boost::end(rng));
|
||||
}
|
||||
}
|
||||
|
||||
template<class SinglePassRange>
|
||||
inline BOOST_DEDUCED_TYPENAME range_size<const SinglePassRange>::type
|
||||
inline typename range_size<const SinglePassRange>::type
|
||||
size(const SinglePassRange& rng)
|
||||
{
|
||||
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
|
||||
|
@ -31,14 +31,18 @@
|
||||
|
||||
namespace boost
|
||||
{
|
||||
|
||||
|
||||
template< class ForwardRange >
|
||||
class sub_range : public iterator_range< BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type >
|
||||
class sub_range
|
||||
: public iterator_range<
|
||||
BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type
|
||||
>
|
||||
{
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator_t;
|
||||
typedef iterator_range< iterator_t > base;
|
||||
|
||||
typedef BOOST_DEDUCED_TYPENAME base::impl impl;
|
||||
|
||||
public:
|
||||
typedef BOOST_DEDUCED_TYPENAME range_value<ForwardRange>::type value_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_iterator<ForwardRange>::type iterator;
|
||||
@ -46,17 +50,25 @@ namespace boost
|
||||
typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
|
||||
typedef BOOST_DEDUCED_TYPENAME base::reference reference;
|
||||
|
||||
public: // for return value of front/back
|
||||
typedef BOOST_DEDUCED_TYPENAME
|
||||
boost::mpl::if_< boost::is_reference<reference>,
|
||||
const BOOST_DEDUCED_TYPENAME boost::remove_reference<reference>::type&,
|
||||
reference >::type const_reference;
|
||||
|
||||
private:
|
||||
template<class Source>
|
||||
struct is_compatible_range
|
||||
: is_convertible<
|
||||
BOOST_DEDUCED_TYPENAME mpl::eval_if<
|
||||
has_range_iterator<Source>,
|
||||
range_iterator<Source>,
|
||||
mpl::identity<void>
|
||||
>::type,
|
||||
iterator
|
||||
>
|
||||
{
|
||||
};
|
||||
|
||||
public:
|
||||
sub_range() : base()
|
||||
sub_range()
|
||||
{ }
|
||||
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500) )
|
||||
sub_range( const sub_range& r )
|
||||
: base( static_cast<const base&>( r ) )
|
||||
@ -64,39 +76,57 @@ namespace boost
|
||||
#endif
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range( ForwardRange2& r ) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif
|
||||
{ }
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range( const ForwardRange2& r ) :
|
||||
sub_range(
|
||||
ForwardRange2& r,
|
||||
BOOST_DEDUCED_TYPENAME enable_if<
|
||||
is_compatible_range<ForwardRange2>
|
||||
>::type* = 0
|
||||
) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif
|
||||
#endif
|
||||
{ }
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range(
|
||||
const ForwardRange2& r,
|
||||
BOOST_DEDUCED_TYPENAME enable_if<
|
||||
is_compatible_range<const ForwardRange2>
|
||||
>::type* = 0
|
||||
) :
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 800 )
|
||||
base( impl::adl_begin( r ), impl::adl_end( r ) )
|
||||
#else
|
||||
base( r )
|
||||
#endif
|
||||
{ }
|
||||
|
||||
template< class Iter >
|
||||
sub_range( Iter first, Iter last ) :
|
||||
base( first, last )
|
||||
{ }
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range& operator=( ForwardRange2& r )
|
||||
|
||||
template<class ForwardRange2>
|
||||
BOOST_DEDUCED_TYPENAME enable_if<
|
||||
is_compatible_range<ForwardRange2>,
|
||||
sub_range&
|
||||
>::type
|
||||
operator=(ForwardRange2& r)
|
||||
{
|
||||
base::operator=( r );
|
||||
return *this;
|
||||
}
|
||||
|
||||
template< class ForwardRange2 >
|
||||
sub_range& operator=( const ForwardRange2& r )
|
||||
template<class ForwardRange2>
|
||||
BOOST_DEDUCED_TYPENAME enable_if<
|
||||
is_compatible_range<const ForwardRange2>,
|
||||
sub_range&
|
||||
>::type
|
||||
operator=( const ForwardRange2& r )
|
||||
{
|
||||
base::operator=( r );
|
||||
return *this;
|
||||
@ -107,71 +137,8 @@ namespace boost
|
||||
base::operator=( static_cast<const base&>(r) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
iterator begin() { return base::begin(); }
|
||||
const_iterator begin() const { return base::begin(); }
|
||||
iterator end() { return base::end(); }
|
||||
const_iterator end() const { return base::end(); }
|
||||
difference_type size() const { return base::size(); }
|
||||
|
||||
|
||||
public: // convenience
|
||||
reference front()
|
||||
{
|
||||
return base::front();
|
||||
}
|
||||
|
||||
const_reference front() const
|
||||
{
|
||||
return base::front();
|
||||
}
|
||||
|
||||
reference back()
|
||||
{
|
||||
return base::back();
|
||||
}
|
||||
|
||||
const_reference back() const
|
||||
{
|
||||
return base::back();
|
||||
}
|
||||
|
||||
reference operator[]( difference_type sz )
|
||||
{
|
||||
return base::operator[](sz);
|
||||
}
|
||||
|
||||
const_reference operator[]( difference_type sz ) const
|
||||
{
|
||||
return base::operator[](sz);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template< class ForwardRange, class ForwardRange2 >
|
||||
inline bool operator==( const sub_range<ForwardRange>& l,
|
||||
const sub_range<ForwardRange2>& r )
|
||||
{
|
||||
return boost::equal( l, r );
|
||||
}
|
||||
|
||||
template< class ForwardRange, class ForwardRange2 >
|
||||
inline bool operator!=( const sub_range<ForwardRange>& l,
|
||||
const sub_range<ForwardRange2>& r )
|
||||
{
|
||||
return !boost::equal( l, r );
|
||||
}
|
||||
|
||||
template< class ForwardRange, class ForwardRange2 >
|
||||
inline bool operator<( const sub_range<ForwardRange>& l,
|
||||
const sub_range<ForwardRange2>& r )
|
||||
{
|
||||
return iterator_range_detail::less_than( l, r );
|
||||
}
|
||||
|
||||
|
||||
} // namespace 'boost'
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
|
||||
|
Reference in New Issue
Block a user