From 744dbcbbc71a624caf0b49d8fab909958c4bba02 Mon Sep 17 00:00:00 2001 From: Joel de Guzman Date: Fri, 12 Aug 2011 05:13:03 +0000 Subject: [PATCH] added case for equal_to that returns false immediately if the tags are different in the first place [SVN r73685] --- include/boost/fusion/iterator/equal_to.hpp | 20 ++++++++++++++----- .../fusion/iterator/iterator_adapter.hpp | 19 +++++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/include/boost/fusion/iterator/equal_to.hpp b/include/boost/fusion/iterator/equal_to.hpp index a0387417..26bb8d43 100644 --- a/include/boost/fusion/iterator/equal_to.hpp +++ b/include/boost/fusion/iterator/equal_to.hpp @@ -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 @@ namespace boost { namespace fusion template <> struct equal_to_impl { - template - struct apply : I1::template equal_to {}; + template + struct dispatch : mpl::false_ {}; + + template + struct dispatch // same tag + : It1::template equal_to + {}; + + template + struct apply : dispatch + {}; }; template <> @@ -63,7 +73,7 @@ namespace boost { namespace fusion namespace iterator_operators { template - inline typename + inline typename enable_if< mpl::and_, is_fusion_iterator > , bool @@ -74,7 +84,7 @@ namespace boost { namespace fusion } template - inline typename + inline typename enable_if< mpl::and_, is_fusion_iterator > , bool diff --git a/include/boost/fusion/iterator/iterator_adapter.hpp b/include/boost/fusion/iterator/iterator_adapter.hpp index 9ba434cb..dea6ddb9 100644 --- a/include/boost/fusion/iterator/iterator_adapter.hpp +++ b/include/boost/fusion/iterator/iterator_adapter.hpp @@ -9,6 +9,7 @@ #include #include +#include namespace boost { namespace fusion { @@ -18,7 +19,9 @@ namespace boost { namespace fusion Derived_ , typename Iterator_::category> { - typedef Iterator_ iterator_base_type; + typedef typename + remove_const::type + iterator_base_type; iterator_base_type iterator_base; iterator_adapter(iterator_base_type const& iterator_base) @@ -36,12 +39,18 @@ namespace boost { namespace fusion // default implementation template 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(it.iterator_base)); + } }; // default implementation