Boost logo

Boost-Commit :

From: nesotto_at_[hidden]
Date: 2007-10-23 15:34:39


Author: nesotto
Date: 2007-10-23 15:34:38 EDT (Tue, 23 Oct 2007)
New Revision: 40375
URL: http://svn.boost.org/trac/boost/changeset/40375

Log:
added operator() to allow random access index with transform iterators
Text files modified:
   trunk/boost/range/iterator_range.hpp | 17 ++++++++++++++---
   1 files changed, 14 insertions(+), 3 deletions(-)

Modified: trunk/boost/range/iterator_range.hpp
==============================================================================
--- trunk/boost/range/iterator_range.hpp (original)
+++ trunk/boost/range/iterator_range.hpp 2007-10-23 15:34:38 EDT (Tue, 23 Oct 2007)
@@ -348,10 +348,21 @@
                return *--last;
            }
     
- reference operator[]( size_type sz ) const
+ reference operator[]( size_type at ) const
            {
- BOOST_ASSERT( sz < size() );
- return m_Begin[sz];
+ BOOST_ASSERT( at < size() );
+ return m_Begin[at];
+ }
+
+ //
+ // When storing transform iterators, operator[]()
+ // fails because it returns by reference. Therefore
+ // operator()() is provided for these cases.
+ //
+ value_type operator()( size_type at ) const
+ {
+ BOOST_ASSERT( at < size() );
+ return m_Begin[at];
            }
 
            iterator_range& advance_begin( difference_type n )


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