annotate DEPENDENCIES/generic/include/boost/fusion/container/map/map_iterator.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Copyright (c) 2005-2013 Joel de Guzman
Chris@16 3 Copyright (c) 2005-2006 Dan Marsden
Chris@16 4
Chris@16 5 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 ==============================================================================*/
Chris@16 8 #if !defined(BOOST_FUSION_MAP_ITERATOR_02042013_0835)
Chris@16 9 #define BOOST_FUSION_MAP_ITERATOR_02042013_0835
Chris@16 10
Chris@101 11 #include <boost/fusion/support/config.hpp>
Chris@16 12 #include <boost/fusion/iterator/iterator_facade.hpp>
Chris@16 13 #include <boost/mpl/minus.hpp>
Chris@16 14 #include <boost/mpl/equal_to.hpp>
Chris@101 15 #include <boost/mpl/if.hpp>
Chris@101 16 #include <boost/utility/declval.hpp>
Chris@101 17 #include <boost/type_traits/is_const.hpp>
Chris@101 18 #include <boost/type_traits/add_const.hpp>
Chris@16 19
Chris@16 20 namespace boost { namespace fusion
Chris@16 21 {
Chris@16 22 struct random_access_traversal_tag;
Chris@16 23
Chris@16 24 template <typename Seq, int Pos>
Chris@16 25 struct map_iterator
Chris@16 26 : iterator_facade<
Chris@16 27 map_iterator<Seq, Pos>
Chris@16 28 , typename Seq::category>
Chris@16 29 {
Chris@16 30 typedef Seq sequence;
Chris@16 31 typedef mpl::int_<Pos> index;
Chris@16 32
Chris@101 33 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Chris@16 34 map_iterator(Seq& seq)
Chris@16 35 : seq_(seq)
Chris@16 36 {}
Chris@16 37
Chris@16 38 template<typename Iterator>
Chris@16 39 struct value_of
Chris@16 40 {
Chris@16 41 typedef typename Iterator::sequence sequence;
Chris@16 42 typedef typename Iterator::index index;
Chris@16 43 typedef
Chris@101 44 decltype(boost::declval<sequence>().get_val(index()))
Chris@16 45 type;
Chris@16 46 };
Chris@16 47
Chris@16 48 template<typename Iterator>
Chris@16 49 struct value_of_data
Chris@16 50 {
Chris@16 51 typedef typename Iterator::sequence sequence;
Chris@16 52 typedef typename Iterator::index index;
Chris@16 53 typedef
Chris@101 54 decltype(boost::declval<sequence>().get_val(index()).second)
Chris@16 55 type;
Chris@16 56 };
Chris@16 57
Chris@16 58 template<typename Iterator>
Chris@16 59 struct key_of
Chris@16 60 {
Chris@16 61 typedef typename Iterator::sequence sequence;
Chris@16 62 typedef typename Iterator::index index;
Chris@101 63 typedef decltype(boost::declval<sequence>().get_key(index())) key_identity_type;
Chris@101 64 typedef typename key_identity_type::type type;
Chris@16 65 };
Chris@16 66
Chris@16 67 template<typename Iterator>
Chris@16 68 struct deref
Chris@16 69 {
Chris@16 70 typedef typename Iterator::sequence sequence;
Chris@16 71 typedef typename Iterator::index index;
Chris@16 72 typedef
Chris@101 73 decltype(boost::declval<sequence>().get(index()))
Chris@16 74 type;
Chris@16 75
Chris@101 76 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Chris@16 77 static type
Chris@16 78 call(Iterator const& it)
Chris@16 79 {
Chris@16 80 return it.seq_.get(typename Iterator::index());
Chris@16 81 }
Chris@16 82 };
Chris@16 83
Chris@16 84 template<typename Iterator>
Chris@16 85 struct deref_data
Chris@16 86 {
Chris@16 87 typedef typename Iterator::sequence sequence;
Chris@16 88 typedef typename Iterator::index index;
Chris@16 89
Chris@101 90 typedef decltype(boost::declval<sequence>().get(index()).second) second_type_;
Chris@101 91
Chris@101 92 typedef typename
Chris@101 93 mpl::if_<
Chris@101 94 is_const<sequence>
Chris@101 95 , typename add_const<second_type_>::type
Chris@101 96 , second_type_
Chris@101 97 >::type
Chris@101 98 second_type;
Chris@101 99
Chris@101 100 typedef typename add_reference<second_type>::type type;
Chris@101 101
Chris@101 102 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Chris@16 103 static type
Chris@16 104 call(Iterator const& it)
Chris@16 105 {
Chris@16 106 return it.seq_.get(typename Iterator::index()).second;
Chris@16 107 }
Chris@16 108 };
Chris@16 109
Chris@16 110 template <typename Iterator, typename N>
Chris@16 111 struct advance
Chris@16 112 {
Chris@16 113 typedef typename Iterator::index index;
Chris@16 114 typedef typename Iterator::sequence sequence;
Chris@16 115 typedef map_iterator<sequence, index::value + N::value> type;
Chris@16 116
Chris@101 117 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Chris@16 118 static type
Chris@16 119 call(Iterator const& i)
Chris@16 120 {
Chris@16 121 return type(i.seq_);
Chris@16 122 }
Chris@16 123 };
Chris@16 124
Chris@16 125 template<typename Iterator>
Chris@16 126 struct next
Chris@16 127 : advance<Iterator, mpl::int_<1> >
Chris@16 128 {};
Chris@16 129
Chris@16 130 template<typename Iterator>
Chris@16 131 struct prior
Chris@16 132 : advance<Iterator, mpl::int_<-1> >
Chris@16 133 {};
Chris@16 134
Chris@16 135 template <typename I1, typename I2>
Chris@16 136 struct distance
Chris@16 137 {
Chris@16 138 typedef typename
Chris@16 139 mpl::minus<
Chris@16 140 typename I2::index, typename I1::index
Chris@16 141 >::type
Chris@16 142 type;
Chris@16 143
Chris@101 144 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
Chris@16 145 static type
Chris@16 146 call(I1 const&, I2 const&)
Chris@16 147 {
Chris@16 148 return type();
Chris@16 149 }
Chris@16 150 };
Chris@16 151
Chris@16 152 template<typename I1, typename I2>
Chris@16 153 struct equal_to
Chris@16 154 : mpl::equal_to<typename I1::index, typename I2::index>
Chris@16 155 {};
Chris@16 156
Chris@16 157 Seq& seq_;
Chris@16 158
Chris@16 159 private:
Chris@16 160 // silence MSVC warning C4512: assignment operator could not be generated
Chris@16 161 map_iterator& operator= (map_iterator const&);
Chris@16 162 };
Chris@16 163
Chris@16 164 }}
Chris@16 165
Chris@101 166 #ifdef BOOST_FUSION_WORKAROUND_FOR_LWG_2408
Chris@101 167 namespace std
Chris@101 168 {
Chris@101 169 template <typename Seq, int Pos>
Chris@101 170 struct iterator_traits< ::boost::fusion::map_iterator<Seq, Pos> >
Chris@101 171 { };
Chris@101 172 }
Chris@16 173 #endif
Chris@101 174
Chris@101 175 #endif