added case for equal_to that returns false immediately if the tags are different in the first place

[SVN r73685]
This commit is contained in:
Joel de Guzman
2011-08-12 05:13:03 +00:00
parent 48a0546eea
commit 744dbcbbc7
2 changed files with 29 additions and 10 deletions

View File

@ -37,8 +37,18 @@ namespace boost { namespace fusion
template <> template <>
struct equal_to_impl<iterator_facade_tag> struct equal_to_impl<iterator_facade_tag>
{ {
template <typename I1, typename I2> template <typename It1, typename It2, typename Tag1, typename Tag2>
struct apply : I1::template equal_to<I1, I2> {}; 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 <> template <>

View File

@ -9,6 +9,7 @@
#include <boost/fusion/iterator/detail/advance.hpp> #include <boost/fusion/iterator/detail/advance.hpp>
#include <boost/fusion/iterator/iterator_facade.hpp> #include <boost/fusion/iterator/iterator_facade.hpp>
#include <boost/type_traits/remove_const.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
{ {
@ -18,7 +19,9 @@ namespace boost { namespace fusion
Derived_ Derived_
, typename Iterator_::category> , typename Iterator_::category>
{ {
typedef Iterator_ iterator_base_type; typedef typename
remove_const<Iterator_>::type
iterator_base_type;
iterator_base_type iterator_base; iterator_base_type iterator_base;
iterator_adapter(iterator_base_type const& iterator_base) iterator_adapter(iterator_base_type const& iterator_base)
@ -36,12 +39,18 @@ namespace boost { namespace fusion
// default implementation // default implementation
template <typename Iterator, typename N> template <typename Iterator, typename N>
struct advance struct advance
: Derived_::template make< {
typedef typename Derived_::template make<
typename result_of::advance< typename result_of::advance<
typename Iterator::iterator_base_type, N 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 // default implementation