Index: iterator_range_core.hpp =================================================================== --- iterator_range_core.hpp (revision 61263) +++ iterator_range_core.hpp (working copy) @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -151,6 +153,15 @@ boost::mpl::if_< boost::is_abstract, reference, value_type >::type abstract_value_type; + // for the return value of operator[] + typedef BOOST_DEDUCED_TYPENAME + boost::mpl::eval_if< + boost::is_pointer, + boost::mpl::identity, + boost::detail::operator_brackets_result + >::type + abstract_reference_type; + public: iterator_range() : m_Begin( iterator() ), m_End( iterator() ) { } @@ -304,15 +315,10 @@ // pointers as iterators. Since a pointer can't have the // issues with proxies this implementation uses a simpler // implementation if the iterator is a pointer. - BOOST_DEDUCED_TYPENAME boost::mpl::if_< - boost::is_pointer, - reference, - BOOST_DEDUCED_TYPENAME boost::detail::operator_brackets_result::type - >::type - operator[]( difference_type at ) const + abstract_reference_type operator[]( difference_type at ) const { BOOST_ASSERT( at >= 0 && at < size() ); - return get_at(m_Begin, at); + return get_at(m_Begin, at, boost::is_pointer()); } #endif @@ -340,22 +346,17 @@ } private: + template - static BOOST_DEDUCED_TYPENAME boost::enable_if< - boost::is_pointer, - reference - >::type - get_at( Iterator it, difference_type at ) + static abstract_reference_type + get_at( Iterator it, difference_type at, boost::mpl::true_ ) { return it[at]; } template - static BOOST_DEDUCED_TYPENAME boost::disable_if< - boost::is_pointer, - BOOST_DEDUCED_TYPENAME boost::detail::operator_brackets_result::type - >::type - get_at( Iterator it, difference_type at ) + static abstract_reference_type + get_at( Iterator it, difference_type at, boost::mpl::false_ ) { typedef boost::detail::use_operator_brackets_proxy use_proxy; return boost::detail::make_operator_brackets_result(it + at, use_proxy());