• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2005-2006 Dan Marsden
4 
5     Distributed under the Boost Software License, Version 1.0. (See accompanying
6     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 ==============================================================================*/
8 #if !defined(BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR)
9 #define BOOST_FUSION_EXAMPLE_STRUCT_ITERATOR
10 
11 #include <boost/fusion/support/iterator_base.hpp>
12 #include <boost/fusion/support/category_of.hpp>
13 #include <boost/fusion/support/tag_of_fwd.hpp>
14 #include <boost/mpl/int.hpp>
15 #include <boost/type_traits/add_const.hpp>
16 #include <boost/static_assert.hpp>
17 
18 #include "./detail/next_impl.hpp"
19 #include "./detail/prior_impl.hpp"
20 #include "./detail/deref_impl.hpp"
21 #include "./detail/advance_impl.hpp"
22 #include "./detail/distance_impl.hpp"
23 #include "./detail/value_of_impl.hpp"
24 #include "./detail/equal_to_impl.hpp"
25 #include "./detail/key_of_impl.hpp"
26 #include "./detail/value_of_data_impl.hpp"
27 #include "./detail/deref_data_impl.hpp"
28 
29 namespace example
30 {
31     struct example_struct_iterator_tag;
32 
33     template<typename Struct, int Pos>
34     struct example_struct_iterator;
35 }
36 
37 namespace boost { namespace fusion {
38 
39     namespace traits
40     {
41         template<typename Struct, int Pos>
42         struct tag_of<example::example_struct_iterator<Struct, Pos> >
43         {
44             typedef example::example_struct_iterator_tag type;
45         };
46     }
47 }}
48 
49 namespace example {
50     template<typename Struct, int Pos>
51     struct example_struct_iterator
52         : boost::fusion::iterator_base<example_struct_iterator<Struct, Pos> >
53     {
54         BOOST_STATIC_ASSERT(Pos >=0 && Pos < 3);
55         typedef Struct struct_type;
56         typedef boost::mpl::int_<Pos> index;
57 
58         struct category
59           : boost::fusion::random_access_traversal_tag
60           , boost::fusion::associative_tag
61         {};
62 
example_struct_iteratorexample::example_struct_iterator63         example_struct_iterator(Struct& str)
64             : struct_(str) {}
65 
66         Struct& struct_;
67     };
68 }
69 
70 #endif
71