1 | /*=============================================================================
|
---|
2 | Copyright (c) 2003 Joel de Guzman
|
---|
3 |
|
---|
4 | Use, modification and distribution is subject to the Boost Software
|
---|
5 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
6 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
7 | ==============================================================================*/
|
---|
8 | #if !defined(FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_EQUAL_TO_TRAITS_HPP)
|
---|
9 | #define FUSION_ITERATOR_DETAIL_TUPLE_ITERATOR_EQUAL_TO_TRAITS_HPP
|
---|
10 |
|
---|
11 | #include <boost/spirit/fusion/detail/config.hpp>
|
---|
12 | #include <boost/type_traits/is_same.hpp>
|
---|
13 | #include <boost/mpl/equal_to.hpp>
|
---|
14 | #include <boost/mpl/and.hpp>
|
---|
15 |
|
---|
16 | namespace boost { namespace fusion
|
---|
17 | {
|
---|
18 | struct tuple_iterator_tag;
|
---|
19 |
|
---|
20 | namespace detail
|
---|
21 | {
|
---|
22 | template <typename I1, typename I2>
|
---|
23 | struct has_same_tags
|
---|
24 | : is_same<FUSION_GET_TAG(I1), FUSION_GET_TAG(I2)> {};
|
---|
25 |
|
---|
26 | template <typename I1, typename I2>
|
---|
27 | struct has_same_index
|
---|
28 | : mpl::equal_to<FUSION_GET_INDEX(I1), FUSION_GET_INDEX(I2)>::type {};
|
---|
29 |
|
---|
30 | template <typename I>
|
---|
31 | struct tuple_identity
|
---|
32 | {
|
---|
33 | typedef typename I::tuple tuple_type;
|
---|
34 | typedef typename tuple_type::identity_type type;
|
---|
35 | };
|
---|
36 |
|
---|
37 | template <typename I1, typename I2>
|
---|
38 | struct has_same_tuple_identity
|
---|
39 | : is_same<
|
---|
40 | typename tuple_identity<I1>::type
|
---|
41 | , typename tuple_identity<I2>::type
|
---|
42 | >
|
---|
43 | {};
|
---|
44 |
|
---|
45 | template <typename I1, typename I2>
|
---|
46 | struct tuple_iterator_equal_to
|
---|
47 | : mpl::and_<
|
---|
48 | has_same_index<I1, I2>
|
---|
49 | , has_same_tuple_identity<I1, I2>
|
---|
50 | >
|
---|
51 | {
|
---|
52 | BOOST_STATIC_ASSERT((has_same_tags<I1, I2>::value));
|
---|
53 | };
|
---|
54 | }
|
---|
55 |
|
---|
56 | namespace meta
|
---|
57 | {
|
---|
58 | template <typename Tag>
|
---|
59 | struct equal_to_impl;
|
---|
60 |
|
---|
61 | template <>
|
---|
62 | struct equal_to_impl<tuple_iterator_tag>
|
---|
63 | {
|
---|
64 | template <typename I1, typename I2>
|
---|
65 | struct apply : detail::tuple_iterator_equal_to<I1, I2> {};
|
---|
66 | };
|
---|
67 | }
|
---|
68 | }}
|
---|
69 |
|
---|
70 | #endif
|
---|
71 |
|
---|