Boost.Range Fix for trac issue #3110 - Multi_array and iterator_range interaction.

This has been fixed by reusing the well proven iterator_facade operator[] mechanism.

[SVN r61029]
This commit is contained in:
Neil Groves
2010-04-03 22:09:29 +00:00
parent d0544400af
commit 71c2ca614c

View File

@ -20,6 +20,7 @@
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/iterator/iterator_traits.hpp> #include <boost/iterator/iterator_traits.hpp>
#include <boost/iterator/iterator_facade.hpp>
#include <boost/type_traits/is_abstract.hpp> #include <boost/type_traits/is_abstract.hpp>
#include <boost/range/functions.hpp> #include <boost/range/functions.hpp>
#include <boost/range/iterator.hpp> #include <boost/range/iterator.hpp>
@ -45,7 +46,7 @@ namespace boost
// The functions adl_begin and adl_end are implemented in a separate // The functions adl_begin and adl_end are implemented in a separate
// class for gcc-2.9x // class for gcc-2.9x
// //
template<typename IteratorT> template<class IteratorT>
struct iterator_range_impl { struct iterator_range_impl {
template< class ForwardRange > template< class ForwardRange >
static IteratorT adl_begin( ForwardRange& r ) static IteratorT adl_begin( ForwardRange& r )
@ -101,7 +102,7 @@ namespace boost
It provides a collection interface, It provides a collection interface,
so it is possible to pass an instance to an algorithm requiring a collection as an input. so it is possible to pass an instance to an algorithm requiring a collection as an input.
*/ */
template<typename IteratorT> template<class IteratorT>
class iterator_range class iterator_range
{ {
protected: // Used by sub_range protected: // Used by sub_range
@ -288,10 +289,13 @@ namespace boost
return *--last; return *--last;
} }
reference operator[]( difference_type at ) const BOOST_DEDUCED_TYPENAME boost::detail::operator_brackets_result<iterator, value_type, reference>::type
operator[]( difference_type at ) const
{ {
BOOST_ASSERT( at >= 0 && at < size() ); BOOST_ASSERT( at >= 0 && at < size() );
return m_Begin[at];
typedef boost::detail::use_operator_brackets_proxy<value_type,reference> use_proxy;
return boost::detail::make_operator_brackets_result<iterator>(m_Begin + at, use_proxy());
} }
// //