Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:46:24

0001 /*=============================================================================
0002     Copyright (c) 2005-2012 Joel de Guzman
0003     Copyright (c) 2005-2006 Dan Marsden
0004 
0005     Distributed under the Boost Software License, Version 1.0. (See accompanying
0006     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 ==============================================================================*/
0008 #if !defined(BOOST_FUSION_DEQUE_ITERATOR_26112006_2154)
0009 #define BOOST_FUSION_DEQUE_ITERATOR_26112006_2154
0010 
0011 #include <boost/fusion/support/config.hpp>
0012 #include <boost/fusion/iterator/iterator_facade.hpp>
0013 #include <boost/fusion/container/deque/detail/keyed_element.hpp>
0014 #include <boost/mpl/int.hpp>
0015 #include <boost/mpl/minus.hpp>
0016 #include <boost/mpl/equal_to.hpp>
0017 #include <boost/mpl/identity.hpp>
0018 #include <boost/mpl/if.hpp>
0019 #include <boost/type_traits/is_const.hpp>
0020 #include <boost/type_traits/add_const.hpp>
0021 #include <boost/type_traits/add_reference.hpp>
0022 
0023 #ifdef _MSC_VER
0024 #  pragma warning(push)
0025 #  pragma warning(disable: 4512) // assignment operator could not be generated.
0026 #endif
0027 
0028 namespace boost { namespace fusion {
0029 
0030     struct bidirectional_traversal_tag;
0031 
0032     template <typename Seq, int Pos>
0033     struct deque_iterator
0034         : iterator_facade<deque_iterator<Seq, Pos>, bidirectional_traversal_tag>
0035     {
0036         typedef Seq sequence;
0037         typedef mpl::int_<Pos> index;
0038 
0039         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0040         deque_iterator(Seq& seq)
0041             : seq_(seq)
0042         {}
0043 
0044         template<typename Iterator>
0045         struct value_of
0046             : detail::keyed_element_value_at<
0047             typename Iterator::sequence, typename Iterator::index>
0048         {};
0049 
0050         template<typename Iterator>
0051         struct deref
0052         {
0053             typedef typename detail::keyed_element_value_at<
0054                 typename Iterator::sequence, typename Iterator::index>::type element_type;
0055 
0056             typedef typename add_reference<
0057                 typename mpl::eval_if<
0058                 is_const<typename Iterator::sequence>,
0059                 add_const<element_type>,
0060                 mpl::identity<element_type> >::type>::type type;
0061 
0062             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0063             static type
0064             call(Iterator const& it)
0065             {
0066                 return it.seq_.get(typename Iterator::index());
0067             }
0068         };
0069 
0070         template <typename Iterator, typename N>
0071         struct advance
0072         {
0073             typedef typename Iterator::index index;
0074             typedef typename Iterator::sequence sequence;
0075             typedef deque_iterator<sequence, index::value + N::value> type;
0076 
0077             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0078             static type
0079             call(Iterator const& i)
0080             {
0081                 return type(i.seq_);
0082             }
0083         };
0084 
0085         template<typename Iterator>
0086         struct next
0087             : advance<Iterator, mpl::int_<1> >
0088         {};
0089 
0090         template<typename Iterator>
0091         struct prior
0092             : advance<Iterator, mpl::int_<-1> >
0093         {};
0094 
0095         template <typename I1, typename I2>
0096         struct distance : mpl::minus<typename I2::index, typename I1::index>
0097         {
0098             typedef typename
0099                 mpl::minus<
0100                     typename I2::index, typename I1::index
0101                 >::type
0102             type;
0103 
0104             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0105             static type
0106             call(I1 const&, I2 const&)
0107             {
0108                 return type();
0109             }
0110         };
0111 
0112         template<typename I1, typename I2>
0113         struct equal_to
0114             : mpl::equal_to<typename I1::index, typename I2::index>
0115         {};
0116 
0117         Seq& seq_;
0118     };
0119 
0120 }}
0121 
0122 #ifdef _MSC_VER
0123 #  pragma warning(pop)
0124 #endif
0125 
0126 #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
0127 namespace std
0128 {
0129     template <typename Seq, int Pos>
0130     struct iterator_traits< ::boost::fusion::deque_iterator<Seq, Pos> >
0131     { };
0132 }
0133 #endif
0134 
0135 #endif