File indexing completed on 2025-01-18 09:31:07
0001
0002
0003
0004
0005
0006
0007
0008 #if !defined(BOOST_FUSION_ARRAY_ITERATOR_26122005_2250)
0009 #define BOOST_FUSION_ARRAY_ITERATOR_26122005_2250
0010
0011 #include <boost/fusion/support/config.hpp>
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
0021 #ifdef _MSC_VER
0022 # pragma warning(push)
0023 # pragma warning(disable: 4512)
0024 #endif
0025
0026 namespace boost { namespace fusion
0027 {
0028 struct random_access_traversal_tag;
0029
0030 template <typename Array, int Pos>
0031 struct array_iterator
0032 : iterator_facade<array_iterator<Array, Pos>, random_access_traversal_tag>
0033 {
0034 BOOST_MPL_ASSERT_RELATION(Pos, >=, 0);
0035 BOOST_MPL_ASSERT_RELATION(Pos, <=, static_cast<int>(Array::static_size));
0036
0037 typedef mpl::int_<Pos> index;
0038 typedef Array array_type;
0039
0040 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0041 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 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0066 static type
0067 call(Iterator const & it)
0068 {
0069 return it.array[Iterator::index::value];
0070 }
0071 };
0072
0073 template <typename Iterator, typename N>
0074 struct advance
0075 {
0076 typedef typename Iterator::index index;
0077 typedef typename Iterator::array_type array_type;
0078 typedef array_iterator<array_type, index::value + N::value> type;
0079
0080 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0081 static type
0082 call(Iterator const& i)
0083 {
0084 return type(i.array);
0085 }
0086 };
0087
0088 template <typename Iterator>
0089 struct next : advance<Iterator, mpl::int_<1> > {};
0090
0091 template <typename Iterator>
0092 struct prior : advance<Iterator, mpl::int_<-1> > {};
0093
0094 template <typename I1, typename I2>
0095 struct distance : mpl::minus<typename I2::index, typename I1::index>
0096 {
0097 typedef typename
0098 mpl::minus<
0099 typename I2::index, typename I1::index
0100 >::type
0101 type;
0102
0103 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0104 static type
0105 call(I1 const&, I2 const&)
0106 {
0107 return type();
0108 }
0109 };
0110 };
0111 }}
0112
0113 #ifdef _MSC_VER
0114 # pragma warning(pop)
0115 #endif
0116
0117 #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
0118 namespace std
0119 {
0120 template <typename Array, int Pos>
0121 struct iterator_traits< ::boost::fusion::array_iterator<Array, Pos> >
0122 { };
0123 }
0124 #endif
0125
0126 #endif