]> git.donarmstrong.com Git - rsem.git/blob - boost/fusion/iterator/equal_to.hpp
Updated boost to v1.55.0
[rsem.git] / boost / fusion / iterator / equal_to.hpp
1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3
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
9
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>
16
17 namespace boost { namespace fusion
18 {
19     // Special tags:
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
24
25     namespace extension
26     {
27         template <typename Tag>
28         struct equal_to_impl
29         {
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             {};
35         };
36
37         template <>
38         struct equal_to_impl<iterator_facade_tag>
39         {
40             template <typename It1, typename It2, typename Tag1, typename Tag2>
41             struct dispatch : mpl::false_ {};
42
43             template <typename It1, typename It2, typename Tag>
44             struct dispatch<It1, It2, Tag, Tag> // same tag
45               : It1::template equal_to<It1, It2>
46             {};
47
48             template<typename It1, typename It2>
49             struct apply : dispatch<It1, It2,
50                 typename It1::fusion_tag, typename It2::fusion_tag>
51             {};
52         };
53
54         template <>
55         struct equal_to_impl<boost_array_iterator_tag>;
56
57         template <>
58         struct equal_to_impl<mpl_iterator_tag>;
59
60         template <>
61         struct equal_to_impl<std_pair_iterator_tag>;
62     }
63
64     namespace result_of
65     {
66         template <typename I1, typename I2>
67         struct equal_to
68             : extension::equal_to_impl<typename detail::tag_of<I1>::type>::
69                 template apply<I1, I2>
70         {};
71     }
72
73     namespace iterator_operators
74     {
75         template <typename Iter1, typename Iter2>
76         inline typename
77         boost::enable_if<
78             mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
79             , bool
80             >::type
81         operator==(Iter1 const&, Iter2 const&)
82         {
83             return result_of::equal_to<Iter1, Iter2>::value;
84         }
85
86         template <typename Iter1, typename Iter2>
87         inline typename
88         boost::enable_if<
89             mpl::and_<is_fusion_iterator<Iter1>, is_fusion_iterator<Iter2> >
90             , bool
91             >::type
92         operator!=(Iter1 const&, Iter2 const&)
93         {
94             return !result_of::equal_to<Iter1, Iter2>::value;
95         }
96     }
97
98     using iterator_operators::operator==;
99     using iterator_operators::operator!=;
100 }}
101
102 #endif
103