1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #if !defined(FUSION_EQUAL_TO_05052005_1208)
8 #define FUSION_EQUAL_TO_05052005_1208
10 #include <boost/type_traits/is_same.hpp>
11 #include <boost/fusion/support/tag_of.hpp>
12 #include <boost/type_traits/add_const.hpp>
13 #include <boost/fusion/support/is_iterator.hpp>
14 #include <boost/mpl/and.hpp>
15 #include <boost/utility/enable_if.hpp>
17 namespace boost { namespace fusion
20 struct iterator_facade_tag; // iterator facade tag
21 struct boost_array_iterator_tag; // boost::array iterator tag
22 struct mpl_iterator_tag; // mpl sequence iterator tag
23 struct std_pair_iterator_tag; // std::pair iterator tag
27 template <typename Tag>
30 // default implementation
31 template <typename I1, typename I2>
33 : is_same<typename add_const<I1>::type, typename add_const<I2>::type>
38 struct equal_to_impl<iterator_facade_tag>
40 template <typename It1, typename It2, typename Tag1, typename Tag2>
41 struct dispatch : mpl::false_ {};
43 template <typename It1, typename It2, typename Tag>
44 struct dispatch<It1, It2, Tag, Tag> // same tag
45 : It1::template equal_to<It1, It2>
48 template<typename It1, typename It2>
49 struct apply : dispatch<It1, It2,
50 typename It1::fusion_tag, typename It2::fusion_tag>
55 struct equal_to_impl<boost_array_iterator_tag>;
58 struct equal_to_impl<mpl_iterator_tag>;
61 struct equal_to_impl<std_pair_iterator_tag>;
66 template <typename I1, typename I2>
68 : extension::equal_to_impl<typename detail::tag_of<I1>::type>::
69 template apply<I1, I2>
73 namespace iterator_operators
75 template <typename Iter1, typename Iter2>
78 mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
81 operator==(Iter1 const&, Iter2 const&)
83 return result_of::equal_to<Iter1, Iter2>::value;
86 template <typename Iter1, typename Iter2>
89 mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
92 operator!=(Iter1 const&, Iter2 const&)
94 return !result_of::equal_to<Iter1, Iter2>::value;
98 using iterator_operators::operator==;
99 using iterator_operators::operator!=;