Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57989 - in trunk: boost/iterator libs/iterator/test
From: dave_at_[hidden]
Date: 2009-11-28 00:12:30


Author: dave
Date: 2009-11-28 00:12:29 EST (Sat, 28 Nov 2009)
New Revision: 57989
URL: http://svn.boost.org/trac/boost/changeset/57989

Log:
Made sure that iterator_facade's nested ``::pointer`` type is always
the same as what's returned from operator->. For input iterators,
that wasn't always the case (see operator_arrow_proxy).

Fixes #1019.

Text files modified:
   trunk/boost/iterator/iterator_facade.hpp | 26 +++++++++++++-------------
   trunk/libs/iterator/test/iterator_facade.cpp | 6 ++++++
   2 files changed, 19 insertions(+), 13 deletions(-)

Modified: trunk/boost/iterator/iterator_facade.hpp
==============================================================================
--- trunk/boost/iterator/iterator_facade.hpp (original)
+++ trunk/boost/iterator/iterator_facade.hpp 2009-11-28 00:12:29 EST (Sat, 28 Nov 2009)
@@ -105,6 +105,7 @@
         
         typedef typename remove_const<ValueParam>::type value_type;
         
+ // Not the real associated pointer type
         typedef typename mpl::eval_if<
             boost::detail::iterator_writability_disabled<ValueParam,Reference>
           , add_pointer<const value_type>
@@ -617,6 +618,12 @@
          Value, CategoryOrTraversal, Reference, Difference
> associated_types;
 
+ typedef boost::detail::operator_arrow_result<
+ typename associated_types::value_type
+ , Reference
+ , typename associated_types::pointer
+ > pointer_;
+
    protected:
       // For use by derived classes
       typedef iterator_facade<Derived,Value,CategoryOrTraversal,Reference,Difference> iterator_facade_;
@@ -626,7 +633,9 @@
       typedef typename associated_types::value_type value_type;
       typedef Reference reference;
       typedef Difference difference_type;
- typedef typename associated_types::pointer pointer;
+
+ typedef typename pointer_::type pointer;
+
       typedef typename associated_types::iterator_category iterator_category;
 
       reference operator*() const
@@ -634,18 +643,9 @@
           return iterator_core_access::dereference(this->derived());
       }
 
- typename boost::detail::operator_arrow_result<
- value_type
- , reference
- , pointer
- >::type
- operator->() const
- {
- return boost::detail::operator_arrow_result<
- value_type
- , reference
- , pointer
- >::make(*this->derived());
+ pointer operator->() const
+ {
+ return pointer_::make(*this->derived());
       }
         
       typename boost::detail::operator_brackets_result<Derived,Value,reference>::type

Modified: trunk/libs/iterator/test/iterator_facade.cpp
==============================================================================
--- trunk/libs/iterator/test/iterator_facade.cpp (original)
+++ trunk/libs/iterator/test/iterator_facade.cpp 2009-11-28 00:12:29 EST (Sat, 28 Nov 2009)
@@ -87,6 +87,10 @@
     }
 };
 
+template <class T, class U>
+void same_type(U const&)
+{ BOOST_MPL_ASSERT((boost::is_same<T,U>)); }
+
 int main()
 {
     int state = 0;
@@ -101,6 +105,8 @@
     input_iter p;
     (*p).mutator();
     p->mutator();
+
+ same_type<input_iter::pointer>(p.operator->());
     
     return boost::report_errors();
 }


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