1 /*=============================================================================
2 Copyright (c) 2013 Mateusz Loskot
3 Copyright (c) 2001-2011 Joel de Guzman
4 Copyright (c) 2005-2006 Dan Marsden
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #if !defined(BOOST_FUSION_STD_ARRAY_ARRAY_ITERATOR_01062013_1700)
10 #define BOOST_FUSION_STD_ARRAY_ARRAY_ITERATOR_01062013_1700
13 #include <boost/config.hpp>
14 #include <boost/mpl/int.hpp>
15 #include <boost/mpl/assert.hpp>
16 #include <boost/mpl/if.hpp>
17 #include <boost/mpl/minus.hpp>
18 #include <boost/type_traits/is_const.hpp>
19 #include <boost/fusion/iterator/iterator_facade.hpp>
20 #include <boost/fusion/adapted/std_array/detail/array_size.hpp>
22 namespace boost { namespace fusion
24 struct random_access_traversal_tag;
26 template <typename Array, int Pos>
27 struct std_array_iterator
28 : iterator_facade<std_array_iterator<Array, Pos>, random_access_traversal_tag>
30 BOOST_MPL_ASSERT_RELATION(Pos, >=, 0);
31 BOOST_MPL_ASSERT_RELATION(Pos, <=, std::tuple_size<Array>::value);
33 typedef mpl::int_<Pos> index;
34 typedef Array array_type;
36 std_array_iterator(Array& a)
41 template <typename Iterator>
44 typedef typename Iterator::array_type array_type;
45 typedef typename array_type::value_type type;
48 template <typename Iterator>
51 typedef typename Iterator::array_type array_type;
55 , typename array_type::const_reference
56 , typename array_type::reference
61 call(Iterator const & it)
63 return it.array[Iterator::index::value];
67 template <typename Iterator, typename N>
70 typedef typename Iterator::index index;
71 typedef typename Iterator::array_type array_type;
72 typedef std_array_iterator<array_type, index::value + N::value> type;
75 call(Iterator const& i)
81 template <typename Iterator>
82 struct next : advance<Iterator, mpl::int_<1> > {};
84 template <typename Iterator>
85 struct prior : advance<Iterator, mpl::int_<-1> > {};
87 template <typename I1, typename I2>
88 struct distance : mpl::minus<typename I2::index, typename I1::index>
92 typename I2::index, typename I1::index
97 call(I1 const&, I2 const&)
105 std_array_iterator<Array, Pos>& operator=(std_array_iterator<Array, Pos> const&);