Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59500 - in sandbox/statistics/iterator: boost/iterator libs/iterator/src
From: erwann.rogard_at_[hidden]
Date: 2010-02-04 19:48:57


Author: e_r
Date: 2010-02-04 19:48:56 EST (Thu, 04 Feb 2010)
New Revision: 59500
URL: http://svn.boost.org/trac/boost/changeset/59500

Log:
m
Text files modified:
   sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp | 28 ++++++++++++----------------
   sandbox/statistics/iterator/libs/iterator/src/main.cpp | 4 +++-
   2 files changed, 15 insertions(+), 17 deletions(-)

Modified: sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp
==============================================================================
--- sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp (original)
+++ sandbox/statistics/iterator/boost/iterator/flatten_iterator.hpp 2010-02-04 19:48:56 EST (Thu, 04 Feb 2010)
@@ -5,23 +5,28 @@
 #ifndef BOOST_ITERATOR_FLATTEN_ITERATOR_HPP_ER_2010
 #define BOOST_ITERATOR_FLATTEN_ITERATOR_HPP_ER_2010
 #include <stdexcept>
-#include <boost/mpl/if.hpp>
+//#include <boost/mpl/if.hpp>
 #include <boost/next_prior.hpp>
-#include <boost/iterator/iterator_traits.hpp>
 #include <boost/range.hpp>
+#include <boost/type_traits.hpp>
+#include <boost/iterator/iterator_traits.hpp>
 #include <boost/iterator/iterator_facade.hpp>
 
 // As per M.P.'s suggestion
 
 namespace boost{
 
-
         template<typename It>
         struct flatten_iterator_nested
     {
             typedef typename boost::iterator_reference<It>::type ref_range_;
         typedef typename boost::remove_reference<ref_range_>::type range_;
- typedef typename boost::range_iterator<range_>::type it_;
+
+ // Why const? That's need to be made rigorous. For now it just works
+ // in cases it doesn't without
+ typedef typename boost::range_iterator<
+ typename boost::add_const<range_>::type
+ >::type it_;
         typedef typename boost::iterator_reference<it_>::type ref_;
         typedef typename boost::remove_cv<
                 typename boost::remove_reference<ref_>::type
@@ -35,23 +40,16 @@
                 // TODO
             // weaker of outer and inner iterator
         // also not allowed decremment and advance(n<0)
-
     };
-
     
         template<
             class It,
- bool is_ref = true,
         typename C = random_access_traversal_tag,
- typename R = typename boost::mpl::if_c<
- is_ref,
- typename flatten_iterator_nested<It>::ref_,
- typename flatten_iterator_nested<It>::val_
- >::type,
+ typename R = typename flatten_iterator_nested<It>::ref_,
         typename D = typename flatten_iterator_nested<It>::diff_
>
         class flatten_iterator : public boost::iterator_facade<
- flatten_iterator<It,is_ref,C,R,D>
+ flatten_iterator<It,C,R,D>
       , typename flatten_iterator_nested<It>::val_
       , C
       , R
@@ -61,7 +59,7 @@
                 typedef typename nested_::it_ nit_;
 
                 typedef typename boost::iterator_facade<
- flatten_iterator<It,is_ref,C,R,D>
+ flatten_iterator<It,C,R,D>
                       , typename flatten_iterator_nested<It>::val_
                       , C
                       , R
@@ -222,11 +220,9 @@
             }
                         return d;
         }
-
         
         };
 
-
         template<typename It>
     flatten_iterator<It>
         make_flatten_iterator(It b,It e){

Modified: sandbox/statistics/iterator/libs/iterator/src/main.cpp
==============================================================================
--- sandbox/statistics/iterator/libs/iterator/src/main.cpp (original)
+++ sandbox/statistics/iterator/libs/iterator/src/main.cpp 2010-02-04 19:48:56 EST (Thu, 04 Feb 2010)
@@ -2,12 +2,14 @@
 //#include <libs/iterator/example/range_cycle.h>
 //#include <libs/iterator/example/cycle_iter.h>
 #include <libs/iterator/example/flatten_iterator.h>
+#include <libs/iterator/example/flatten_iterator2.h>
 
 int main () {
 
     //example_range_cycle(std::cout);
     //example_iter(std::cout);
- example_flatten_iterator(std::cout);
+ //example_flatten_iterator(std::cout);
+ example_flatten_iterator2(std::cout);
     
     return 0;
 }


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