Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:49:27

0001 /*=============================================================================
0002     Copyright (c) 2009 Christopher Schmidt
0003 
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 
0008 #ifndef BOOST_FUSION_ITERATOR_BASIC_ITERATOR_HPP
0009 #define BOOST_FUSION_ITERATOR_BASIC_ITERATOR_HPP
0010 
0011 #include <boost/fusion/support/config.hpp>
0012 #include <boost/fusion/iterator/iterator_facade.hpp>
0013 
0014 #include <boost/mpl/and.hpp>
0015 #include <boost/mpl/equal_to.hpp>
0016 #include <boost/mpl/minus.hpp>
0017 #include <boost/mpl/int.hpp>
0018 #include <boost/type_traits/is_same.hpp>
0019 #include <boost/type_traits/remove_const.hpp>
0020 
0021 namespace boost { namespace fusion
0022 {
0023     namespace extension
0024     {
0025         template <typename>
0026         struct value_of_impl;
0027 
0028         template <typename>
0029         struct deref_impl;
0030 
0031         template <typename>
0032         struct value_of_data_impl;
0033 
0034         template <typename>
0035         struct key_of_impl;
0036 
0037         template <typename>
0038         struct deref_data_impl;
0039     }
0040 
0041     template<typename Tag, typename Category, typename Seq, int Index>
0042     struct basic_iterator
0043       : iterator_facade<basic_iterator<Tag, Category, Seq, Index>, Category>
0044     {
0045         typedef mpl::int_<Index> index;
0046         typedef Seq seq_type;
0047 
0048         template <typename It>
0049         struct value_of
0050           : extension::value_of_impl<Tag>::template apply<It>
0051         {};
0052 
0053         template <typename It>
0054         struct deref
0055           : extension::deref_impl<Tag>::template apply<It>
0056         {};
0057 
0058         template <typename It>
0059         struct value_of_data
0060           : extension::value_of_data_impl<Tag>::template apply<It>
0061         {};
0062 
0063         template <typename It>
0064         struct key_of
0065           : extension::key_of_impl<Tag>::template apply<It>
0066         {};
0067 
0068         template <typename It>
0069         struct deref_data
0070           : extension::deref_data_impl<Tag>::template apply<It>
0071         {};
0072 
0073         template <typename It, typename N>
0074         struct advance
0075         {
0076             typedef
0077                 basic_iterator<Tag, Category, Seq, Index + N::value>
0078             type;
0079 
0080             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0081             static type
0082             call(It const& it)
0083             {
0084                 return type(*it.seq,0);
0085             }
0086         };
0087 
0088         template <typename It>
0089         struct next
0090           : advance<It, mpl::int_<1> >
0091         {};
0092 
0093         template <typename It>
0094         struct prior
0095           : advance<It, mpl::int_<-1> >
0096         {};
0097 
0098         template <typename It1, typename It2>
0099         struct distance
0100         {
0101             typedef mpl::minus<typename It2::index, typename It1::index> type;
0102 
0103             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0104             static
0105             type
0106             call(It1 const&, It2 const&)
0107             {
0108                 return type();
0109             }
0110         };
0111 
0112         template <typename It1, typename It2>
0113         struct equal_to
0114           : mpl::and_<
0115                 is_same<
0116                     typename remove_const<typename It1::seq_type>::type
0117                   , typename remove_const<typename It2::seq_type>::type
0118                 >
0119               , mpl::equal_to<typename It1::index,typename It2::index>
0120             >
0121         {};
0122 
0123         template<typename OtherSeq>
0124         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0125         basic_iterator(basic_iterator<Tag,Category,OtherSeq,Index> const& it)
0126           : seq(it.seq)
0127         {}
0128 
0129         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0130         basic_iterator(Seq& in_seq, int)
0131           : seq(&in_seq)
0132         {}
0133 
0134         template<typename OtherSeq>
0135         BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0136         basic_iterator&
0137         operator=(basic_iterator<Tag,Category,OtherSeq,Index> const& it)
0138         {
0139             seq=it.seq;
0140             return *this;
0141         }
0142 
0143         Seq* seq;
0144     };
0145 }}
0146 
0147 #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
0148 namespace std
0149 {
0150     template <typename Tag, typename Category, typename Seq, int Index>
0151     struct iterator_traits< ::boost::fusion::basic_iterator<Tag, Category, Seq, Index> >
0152     { };
0153 }
0154 #endif
0155 
0156 #endif