Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*=============================================================================
0002     Copyright (c) 2001-2011 Joel de Guzman
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 #if !defined(FUSION_STD_TUPLE_ITERATOR_09112011_1905)
0008 #define FUSION_STD_TUPLE_ITERATOR_09112011_1905
0009 
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/fusion/iterator/iterator_facade.hpp>
0012 #include <boost/type_traits/is_const.hpp>
0013 #include <boost/type_traits/remove_const.hpp>
0014 #include <boost/fusion/support/detail/access.hpp>
0015 #include <boost/mpl/int.hpp>
0016 #include <boost/mpl/if.hpp>
0017 #include <tuple>
0018 #include <utility>
0019 
0020 #ifdef _MSC_VER
0021 #  pragma warning(push)
0022 #  pragma warning(disable: 4512) // assignment operator could not be generated.
0023 #endif
0024 
0025 namespace boost { namespace fusion
0026 {
0027     struct random_access_traversal_tag;
0028 
0029     template <typename Tuple, int Index>
0030     struct std_tuple_iterator_identity;
0031 
0032     template <typename Tuple, int Index>
0033     struct std_tuple_iterator
0034         : iterator_facade<
0035               std_tuple_iterator<Tuple, Index>
0036             , random_access_traversal_tag>
0037     {
0038         typedef Tuple tuple_type;
0039         static int const index = Index;
0040         typedef std_tuple_iterator_identity<
0041             typename add_const<Tuple>::type, Index>
0042         identity;
0043 
0044         BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0045         explicit std_tuple_iterator(Tuple& tuple)
0046           : tuple(tuple) {}
0047 
0048         Tuple& tuple;
0049 
0050         template <typename Iterator>
0051         struct value_of
0052           : std::tuple_element<Iterator::index,
0053               typename remove_const<typename Iterator::tuple_type>::type> {};
0054 
0055         template <typename Iterator>
0056         struct deref
0057         {
0058             typedef typename value_of<Iterator>::type element;
0059             typedef typename
0060                 mpl::if_<
0061                     is_const<typename Iterator::tuple_type>
0062                   , typename fusion::detail::cref_result<element>::type
0063                   , typename fusion::detail::ref_result<element>::type
0064                 >::type
0065             type;
0066 
0067             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0068             static type
0069             call(Iterator const& iter)
0070             {
0071                 return std::get<Index>(iter.tuple);
0072             }
0073         };
0074 
0075         template <typename Iterator, typename N>
0076         struct advance
0077         {
0078             static int const index = Iterator::index;
0079             typedef typename Iterator::tuple_type tuple_type;
0080             typedef std_tuple_iterator<tuple_type, index+N::value> type;
0081 
0082             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0083             static type
0084             call(Iterator const& i)
0085             {
0086                 return type(i.tuple);
0087             }
0088         };
0089 
0090         template <typename Iterator>
0091         struct next : advance<Iterator, mpl::int_<1>> {};
0092 
0093         template <typename Iterator>
0094         struct prior : advance<Iterator, mpl::int_<-1>> {};
0095 
0096         template <typename I1, typename I2>
0097         struct equal_to
0098             : is_same<typename I1::identity, typename I2::identity> {};
0099 
0100         template <typename First, typename Last>
0101         struct distance
0102         {
0103             typedef mpl::int_<Last::index-First::index> type;
0104 
0105             BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0106             static type
0107             call(First const&, Last const&)
0108             {
0109                 return type();
0110             }
0111         };
0112     };
0113 }}
0114 
0115 #ifdef _MSC_VER
0116 #  pragma warning(pop)
0117 #endif
0118 
0119 #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
0120 namespace std
0121 {
0122     template <typename Tuple, int Index>
0123     struct iterator_traits< ::boost::fusion::std_tuple_iterator<Tuple, Index> >
0124     { };
0125 }
0126 #endif
0127 
0128 #endif
0129 
0130