Boost logo

Boost-Commit :

From: nesotto_at_[hidden]
Date: 2008-06-12 06:00:54


Author: nesotto
Date: 2008-06-12 06:00:54 EDT (Thu, 12 Jun 2008)
New Revision: 46345
URL: http://svn.boost.org/trac/boost/changeset/46345

Log:
fixes for problems from Trac
Text files modified:
   trunk/boost/range/iterator_range.hpp | 12 +++++++-----
   trunk/boost/range/sub_range.hpp | 14 +++++++++++---
   2 files changed, 18 insertions(+), 8 deletions(-)

Modified: trunk/boost/range/iterator_range.hpp
==============================================================================
--- trunk/boost/range/iterator_range.hpp (original)
+++ trunk/boost/range/iterator_range.hpp 2008-06-12 06:00:54 EDT (Thu, 12 Jun 2008)
@@ -185,7 +185,7 @@
                 m_Begin(Begin), m_End(End)
                 #ifndef NDEBUG
             , singular(false)
- #endif
+ #endif
             {}
 
             //! Constructor from a Range
@@ -210,7 +210,7 @@
             template< class Range >
             iterator_range( const Range& r, iterator_range_detail::const_range_tag ) :
                 m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
- #ifndef NDEBUG
+ #ifndef NDEBUG
             , singular(false)
                 #endif
             {}
@@ -219,7 +219,7 @@
             template< class Range >
             iterator_range( Range& r, iterator_range_detail::range_tag ) :
                 m_Begin( impl::adl_begin( r ) ), m_End( impl::adl_end( r ) )
- #ifndef NDEBUG
+ #ifndef NDEBUG
             , singular(false)
                 #endif
             {}
@@ -390,13 +390,15 @@
             bool singular;
             #endif
 
- #ifndef NDEBUG
         public:
             bool is_singular() const
             {
+ #ifndef NDEBUG
                  return singular;
+ #else
+ return false;
+ #endif
             }
- #endif
 
         protected:
             //

Modified: trunk/boost/range/sub_range.hpp
==============================================================================
--- trunk/boost/range/sub_range.hpp (original)
+++ trunk/boost/range/sub_range.hpp 2008-06-12 06:00:54 EDT (Thu, 12 Jun 2008)
@@ -23,6 +23,8 @@
 #include <boost/range/size_type.hpp>
 #include <boost/range/difference_type.hpp>
 #include <boost/assert.hpp>
+#include <boost/type_traits/is_reference.hpp>
+#include <boost/type_traits/remove_reference.hpp>
 
 namespace boost
 {
@@ -41,6 +43,12 @@
         typedef BOOST_DEDUCED_TYPENAME range_difference<ForwardRange>::type difference_type;
         typedef BOOST_DEDUCED_TYPENAME range_size<ForwardRange>::type size_type;
         typedef BOOST_DEDUCED_TYPENAME base::reference reference;
+
+ public: // for return value of front/back
+ typedef BOOST_DEDUCED_TYPENAME
+ boost::mpl::if_< boost::is_reference<reference>,
+ const BOOST_DEDUCED_TYPENAME boost::remove_reference<reference>::type&,
+ reference >::type const_reference;
 
     public:
         sub_range() : base()
@@ -112,7 +120,7 @@
             return base::front();
         }
 
- const value_type& front() const
+ const_reference front() const
         {
             return base::front();
         }
@@ -122,7 +130,7 @@
             return base::back();
         }
 
- const value_type& back() const
+ const_reference back() const
         {
             return base::back();
         }
@@ -132,7 +140,7 @@
             return base::operator[](sz);
         }
 
- const value_type& operator[]( difference_type sz ) const
+ const_reference operator[]( difference_type sz ) const
         {
             return base::operator[](sz);
         }


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