fix doc example typo
[boost.git] / boost / fusion / iterator / equal_to.hpp
blob2db276752044088d31e35d1e808153a82742d84b
1 /*=============================================================================
2 Copyright (c) 2001-2006 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
19 // Special tags:
20 struct iterator_facade_tag; // iterator facade tag
21 struct 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
25 namespace extension
27 template <typename Tag>
28 struct equal_to_impl
30 // default implementation
31 template <typename I1, typename I2>
32 struct apply
33 : is_same<typename add_const<I1>::type, typename add_const<I2>::type>
34 {};
37 template <>
38 struct equal_to_impl<iterator_facade_tag>
40 template <typename I1, typename I2>
41 struct apply : I1::template equal_to<I1, I2> {};
44 template <>
45 struct equal_to_impl<array_iterator_tag>;
47 template <>
48 struct equal_to_impl<mpl_iterator_tag>;
50 template <>
51 struct equal_to_impl<std_pair_iterator_tag>;
54 namespace result_of
56 template <typename I1, typename I2>
57 struct equal_to
58 : extension::equal_to_impl<typename detail::tag_of<I1>::type>::
59 template apply<I1, I2>
60 {};
63 namespace iterator_operators
65 template <typename Iter1, typename Iter2>
66 inline typename
67 enable_if<
68 mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
69 , bool
70 >::type
71 operator==(Iter1 const&, Iter2 const&)
73 return result_of::equal_to<Iter1, Iter2>::value;
76 template <typename Iter1, typename Iter2>
77 inline typename
78 enable_if<
79 mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
80 , bool
81 >::type
82 operator!=(Iter1 const&, Iter2 const&)
84 return !result_of::equal_to<Iter1, Iter2>::value;
88 using iterator_operators::operator==;
89 using iterator_operators::operator!=;
92 #endif