forked from boostorg/range
trac 5816 - fix any_range requiring copyable elements.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user