From ec3c98bc25fb99a63fccf16a0a4ef38621293f20 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Wed, 7 May 2014 00:13:09 +0100 Subject: [PATCH] any_iterator now compiles without RTTI. --- .../range/detail/any_iterator_wrapper.hpp | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/include/boost/range/detail/any_iterator_wrapper.hpp b/include/boost/range/detail/any_iterator_wrapper.hpp index 2526aa8..c542d39 100644 --- a/include/boost/range/detail/any_iterator_wrapper.hpp +++ b/include/boost/range/detail/any_iterator_wrapper.hpp @@ -19,6 +19,16 @@ namespace boost { namespace range_detail { + template + TargetT& polymorphic_ref_downcast(SourceT& source) + { +#ifdef BOOST_NO_RTTI + return static_cast(source); +#else + return *boost::polymorphic_downcast(&source); +#endif + } + template Reference dereference_cast(T& x) { @@ -192,7 +202,7 @@ namespace boost virtual bool equal(const any_single_pass_iterator_interface& other) const { - return m_it == boost::polymorphic_downcast(&other)->m_it; + return m_it == range_detail::polymorphic_ref_downcast(other).m_it; } virtual reference dereference() const @@ -284,7 +294,7 @@ namespace boost virtual bool equal(const any_single_pass_iterator_interface& other) const { - return m_it == boost::polymorphic_downcast(&other)->m_it; + return m_it == range_detail::polymorphic_ref_downcast(other).m_it; } virtual reference dereference() const @@ -381,7 +391,7 @@ namespace boost virtual bool equal(const any_single_pass_iterator_interface& other) const { - return m_it == boost::polymorphic_downcast(&other)->m_it; + return m_it == range_detail::polymorphic_ref_downcast(other).m_it; } virtual reference dereference() const @@ -482,7 +492,7 @@ namespace boost virtual bool equal(const any_single_pass_iterator_interface& other) const { - return m_it == boost::polymorphic_downcast(&other)->m_it; + return m_it == range_detail::polymorphic_ref_downcast(other).m_it; } virtual void decrement() @@ -502,7 +512,7 @@ namespace boost virtual Difference distance_to(const any_random_access_iterator_interface& other) const { - return boost::polymorphic_downcast(&other)->m_it - m_it; + return range_detail::polymorphic_ref_downcast(other).m_it - m_it; } private: