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_ITERATOR_FACADE_09252006_1011) |
8 | #define FUSION_ITERATOR_FACADE_09252006_1011 |
9 | |
10 | #include <boost/fusion/support/config.hpp> |
11 | #include <boost/fusion/support/iterator_base.hpp> |
12 | #include <boost/fusion/iterator/detail/advance.hpp> |
13 | #include <boost/fusion/iterator/detail/distance.hpp> |
14 | #include <boost/fusion/support/category_of.hpp> |
15 | #include <boost/type_traits/is_same.hpp> |
16 | #include <boost/mpl/assert.hpp> |
17 | #include <boost/mpl/if.hpp> |
18 | |
19 | namespace boost { namespace fusion |
20 | { |
21 | struct iterator_facade_tag; |
22 | |
23 | template <typename Derived, typename Category> |
24 | struct iterator_facade : iterator_base<Derived> |
25 | { |
26 | typedef iterator_facade_tag fusion_tag; |
27 | typedef Derived derived_type; |
28 | typedef Category category; |
29 | |
30 | // default implementation |
31 | template <typename I1, typename I2> |
32 | struct equal_to // default implementation |
33 | : is_same< |
34 | typename I1::derived_type |
35 | , typename I2::derived_type |
36 | > |
37 | {}; |
38 | |
39 | // default implementation |
40 | template <typename Iterator, typename N> |
41 | struct advance : |
42 | mpl::if_c< |
43 | (N::value > 0) |
44 | , advance_detail::forward<Iterator, N::value> |
45 | , advance_detail::backward<Iterator, N::value> |
46 | >::type |
47 | { |
48 | BOOST_MPL_ASSERT_NOT((traits::is_random_access<Iterator>)); |
49 | }; |
50 | |
51 | // default implementation |
52 | template <typename First, typename Last> |
53 | struct distance : |
54 | distance_detail::linear_distance<First, Last> |
55 | {}; |
56 | }; |
57 | }} |
58 | |
59 | #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408 |
60 | namespace std |
61 | { |
62 | template <typename Derived, typename Category> |
63 | struct iterator_traits< ::boost::fusion::iterator_facade<Derived, Category> > |
64 | { }; |
65 | } |
66 | #endif |
67 | |
68 | #endif |
69 | |