Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:31:07

0001 /*=============================================================================
0002     Copyright (c) 2013 Mateusz Loskot
0003     Copyright (c) 2001-2011 Joel de Guzman
0004     Copyright (c) 2005-2006 Dan Marsden
0005 
0006     Distributed under the Boost Software License, Version 1.0. (See accompanying 
0007     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0008 ==============================================================================*/
0009 #if !defined(BOOST_FUSION_STD_ARRAY_ARRAY_ITERATOR_01062013_1700)
0010 #define BOOST_FUSION_STD_ARRAY_ARRAY_ITERATOR_01062013_1700
0011 
0012 #include <cstddef>
0013 #include <boost/config.hpp>
0014 #include <boost/mpl/int.hpp>
0015 #include <boost/mpl/assert.hpp>
0016 #include <boost/mpl/if.hpp>
0017 #include <boost/mpl/minus.hpp>
0018 #include <boost/type_traits/is_const.hpp>
0019 #include <boost/fusion/iterator/iterator_facade.hpp>
0020 #include <boost/fusion/adapted/std_array/detail/array_size.hpp>
0021 
0022 #ifdef _MSC_VER
0023 #  pragma warning(push)
0024 #  pragma warning(disable: 4512) // assignment operator could not be generated.
0025 #endif
0026 
0027 namespace boost { namespace fusion
0028 {
0029     struct random_access_traversal_tag;
0030 
0031     template <typename Array, int Pos>
0032     struct std_array_iterator
0033         : iterator_facade<std_array_iterator<Array, Pos>, random_access_traversal_tag>
0034     {
0035         BOOST_MPL_ASSERT_RELATION(Pos, >=, 0);
0036         BOOST_MPL_ASSERT_RELATION(Pos, <=, std::tuple_size<Array>::value);
0037 
0038         typedef mpl::int_<Pos> index;
0039         typedef Array array_type;
0040 
0041         std_array_iterator(Array& a)
0042             : array(a) {}
0043 
0044         Array& array;
0045 
0046         template <typename Iterator>
0047         struct value_of
0048         {
0049             typedef typename Iterator::array_type array_type;
0050             typedef typename array_type::value_type type;
0051         };
0052 
0053         template <typename Iterator>
0054         struct deref
0055         {
0056             typedef typename Iterator::array_type array_type;
0057             typedef typename 
0058                 mpl::if_<
0059                     is_const<array_type>
0060                   , typename array_type::const_reference
0061                   , typename array_type::reference
0062                 >::type 
0063             type;
0064 
0065             static type
0066             call(Iterator const & it)
0067             {
0068                 return it.array[Iterator::index::value];
0069             }
0070         };
0071 
0072         template <typename Iterator, typename N>
0073         struct advance
0074         {
0075             typedef typename Iterator::index index;
0076             typedef typename Iterator::array_type array_type;
0077             typedef std_array_iterator<array_type, index::value + N::value> type;
0078 
0079             static type
0080             call(Iterator const& i)
0081             {
0082                 return type(i.array);
0083             }
0084         };
0085 
0086         template <typename Iterator>
0087         struct next : advance<Iterator, mpl::int_<1> > {};
0088 
0089         template <typename Iterator>
0090         struct prior : advance<Iterator, mpl::int_<-1> > {};
0091 
0092         template <typename I1, typename I2>
0093         struct distance : mpl::minus<typename I2::index, typename I1::index>
0094         {
0095             typedef typename
0096                 mpl::minus<
0097                     typename I2::index, typename I1::index
0098                 >::type 
0099             type;
0100 
0101             static type
0102             call(I1 const&, I2 const&)
0103             {
0104                 return type();
0105             }
0106         };
0107     };
0108 }}
0109 
0110 #ifdef _MSC_VER
0111 #  pragma warning(pop)
0112 #endif
0113 
0114 #endif