Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73685 - trunk/boost/fusion/iterator
From: joel_at_[hidden]
Date: 2011-08-12 01:13:03


Author: djowel
Date: 2011-08-12 01:13:03 EDT (Fri, 12 Aug 2011)
New Revision: 73685
URL: http://svn.boost.org/trac/boost/changeset/73685

Log:
added case for equal_to that returns false immediately if the tags are different in the first place
Text files modified:
   trunk/boost/fusion/iterator/equal_to.hpp | 20 +++++++++++++++-----
   trunk/boost/fusion/iterator/iterator_adapter.hpp | 19 ++++++++++++++-----
   2 files changed, 29 insertions(+), 10 deletions(-)

Modified: trunk/boost/fusion/iterator/equal_to.hpp
==============================================================================
--- trunk/boost/fusion/iterator/equal_to.hpp (original)
+++ trunk/boost/fusion/iterator/equal_to.hpp 2011-08-12 01:13:03 EDT (Fri, 12 Aug 2011)
@@ -1,7 +1,7 @@
 /*=============================================================================
     Copyright (c) 2001-2006 Joel de Guzman
 
- Distributed under the Boost Software License, Version 1.0. (See accompanying
+ Distributed under the Boost Software License, Version 1.0. (See accompanying
     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 ==============================================================================*/
 #if !defined(FUSION_EQUAL_TO_05052005_1208)
@@ -37,8 +37,18 @@
         template <>
         struct equal_to_impl<iterator_facade_tag>
         {
- template <typename I1, typename I2>
- struct apply : I1::template equal_to<I1, I2> {};
+ template <typename It1, typename It2, typename Tag1, typename Tag2>
+ struct dispatch : mpl::false_ {};
+
+ template <typename It1, typename It2, typename Tag>
+ struct dispatch<It1, It2, Tag, Tag> // same tag
+ : It1::template equal_to<It1, It2>
+ {};
+
+ template<typename It1, typename It2>
+ struct apply : dispatch<It1, It2,
+ typename It1::fusion_tag, typename It2::fusion_tag>
+ {};
         };
 
         template <>
@@ -63,7 +73,7 @@
     namespace iterator_operators
     {
         template <typename Iter1, typename Iter2>
- inline typename
+ inline typename
         enable_if<
             mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
             , bool
@@ -74,7 +84,7 @@
         }
 
         template <typename Iter1, typename Iter2>
- inline typename
+ inline typename
         enable_if<
             mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
             , bool

Modified: trunk/boost/fusion/iterator/iterator_adapter.hpp
==============================================================================
--- trunk/boost/fusion/iterator/iterator_adapter.hpp (original)
+++ trunk/boost/fusion/iterator/iterator_adapter.hpp 2011-08-12 01:13:03 EDT (Fri, 12 Aug 2011)
@@ -9,6 +9,7 @@
 
 #include <boost/fusion/iterator/detail/advance.hpp>
 #include <boost/fusion/iterator/iterator_facade.hpp>
+#include <boost/type_traits/remove_const.hpp>
 
 namespace boost { namespace fusion
 {
@@ -18,7 +19,9 @@
             Derived_
           , typename Iterator_::category>
     {
- typedef Iterator_ iterator_base_type;
+ typedef typename
+ remove_const<Iterator_>::type
+ iterator_base_type;
         iterator_base_type iterator_base;
 
         iterator_adapter(iterator_base_type const& iterator_base)
@@ -36,12 +39,18 @@
         // default implementation
         template <typename Iterator, typename N>
         struct advance
- : Derived_::template make<
+ {
+ typedef typename Derived_::template make<
                 typename result_of::advance<
                     typename Iterator::iterator_base_type, N
- >::type
- >
- {
+ >::type>::type
+ type;
+
+ static type
+ call(Iterator const& it)
+ {
+ return type(fusion::advance<N>(it.iterator_base));
+ }
         };
 
         // default implementation


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