Boost logo

Boost-Commit :

From: nesotto_at_[hidden]
Date: 2008-02-19 10:10:05


Author: nesotto
Date: 2008-02-19 10:10:05 EST (Tue, 19 Feb 2008)
New Revision: 43322
URL: http://svn.boost.org/trac/boost/changeset/43322

Log:
fixed problem with operator()() when the value_type was abstract.
Text files modified:
   trunk/boost/range/iterator_range.hpp | 16 ++++++++++++----
   1 files changed, 12 insertions(+), 4 deletions(-)

Modified: trunk/boost/range/iterator_range.hpp
==============================================================================
--- trunk/boost/range/iterator_range.hpp (original)
+++ trunk/boost/range/iterator_range.hpp 2008-02-19 10:10:05 EST (Tue, 19 Feb 2008)
@@ -28,11 +28,13 @@
 # endif
 #endif // #ifndef BOOST_OLD_IOSTREAMS
 
+#include <boost/assert.hpp>
+#include <boost/iterator/iterator_traits.hpp>
+#include <boost/type_traits/is_abstract.hpp>
 #include <boost/range/functions.hpp>
 #include <boost/range/iterator.hpp>
 #include <boost/range/difference_type.hpp>
-#include <boost/iterator/iterator_traits.hpp>
-#include <boost/assert.hpp>
+#include <boost/utility/enable_if.hpp>
 #include <iterator>
 #include <algorithm>
 #ifndef _STLP_NO_IOSTREAMS
@@ -165,6 +167,12 @@
             //! iterator type
             typedef IteratorT iterator;
 
+ private: // for return value of operator()()
+ typedef BOOST_DEDUCED_TYPENAME
+ boost::mpl::if_< boost::is_abstract<value_type>,
+ reference, value_type >::type abstract_value_type;
+
+ public:
             iterator_range() : m_Begin( iterator() ), m_End( iterator() )
                 #ifndef NDEBUG
             , singular( true )
@@ -352,8 +360,8 @@
            // When storing transform iterators, operator[]()
            // fails because it returns by reference. Therefore
            // operator()() is provided for these cases.
- //
- value_type operator()( difference_type at ) const
+ //
+ abstract_value_type operator()( difference_type at ) const
            {
                BOOST_ASSERT( at >= 0 && at < size() );
                return m_Begin[at];


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk