Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | |
| 2 | // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION |
| 3 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 4 | #if defined(NDNBOOST_PP_IS_ITERATING) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 5 | |
| 6 | // Copyright Aleksey Gurtovoy 2000-2004 |
| 7 | // |
| 8 | // Distributed under the Boost Software License, Version 1.0. |
| 9 | // (See accompanying file LICENSE_1_0.txt or copy at |
| 10 | // http://www.boost.org/LICENSE_1_0.txt) |
| 11 | // |
| 12 | // See http://www.boost.org/libs/mpl for documentation. |
| 13 | |
| 14 | // $Id: numbered.hpp 49267 2008-10-11 06:19:02Z agurtovoy $ |
| 15 | // $Date: 2008-10-10 23:19:02 -0700 (Fri, 10 Oct 2008) $ |
| 16 | // $Revision: 49267 $ |
| 17 | |
| 18 | #include <ndnboost/preprocessor/enum_params.hpp> |
| 19 | #include <ndnboost/preprocessor/enum_shifted_params.hpp> |
| 20 | #include <ndnboost/preprocessor/comma_if.hpp> |
| 21 | #include <ndnboost/preprocessor/repeat.hpp> |
| 22 | #include <ndnboost/preprocessor/dec.hpp> |
| 23 | #include <ndnboost/preprocessor/cat.hpp> |
| 24 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 25 | #define i_ NDNBOOST_PP_FRAME_ITERATION(1) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 26 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 27 | #if defined(NDNBOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 28 | |
| 29 | # define AUX778076_VECTOR_TAIL(vector, i_, T) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 30 | NDNBOOST_PP_CAT(vector,i_)< \ |
| 31 | NDNBOOST_PP_ENUM_PARAMS(i_, T) \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 32 | > \ |
| 33 | /**/ |
| 34 | |
| 35 | #if i_ > 0 |
| 36 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 37 | NDNBOOST_PP_ENUM_PARAMS(i_, typename T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 38 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 39 | struct NDNBOOST_PP_CAT(vector,i_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 40 | : v_item< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 41 | NDNBOOST_PP_CAT(T,NDNBOOST_PP_DEC(i_)) |
| 42 | , AUX778076_VECTOR_TAIL(vector,NDNBOOST_PP_DEC(i_),T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 43 | > |
| 44 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 45 | typedef NDNBOOST_PP_CAT(vector,i_) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 46 | }; |
| 47 | #endif |
| 48 | |
| 49 | # undef AUX778076_VECTOR_TAIL |
| 50 | |
| 51 | #else // "brute force" implementation |
| 52 | |
| 53 | # if i_ > 0 |
| 54 | |
| 55 | template< |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 56 | NDNBOOST_PP_ENUM_PARAMS(i_, typename T) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 57 | > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 58 | struct NDNBOOST_PP_CAT(vector,i_) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 59 | { |
| 60 | typedef aux::vector_tag<i_> tag; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 61 | typedef NDNBOOST_PP_CAT(vector,i_) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 62 | |
| 63 | # define AUX778076_VECTOR_ITEM(unused, i_, unused2) \ |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 64 | typedef NDNBOOST_PP_CAT(T,i_) NDNBOOST_PP_CAT(item,i_); \ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 65 | /**/ |
| 66 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 67 | NDNBOOST_PP_REPEAT(i_, AUX778076_VECTOR_ITEM, unused) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 68 | # undef AUX778076_VECTOR_ITEM |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 69 | typedef void_ NDNBOOST_PP_CAT(item,i_); |
| 70 | typedef NDNBOOST_PP_CAT(T,NDNBOOST_PP_DEC(i_)) back; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 71 | |
| 72 | // Borland forces us to use 'type' here (instead of the class name) |
| 73 | typedef v_iter<type,0> begin; |
| 74 | typedef v_iter<type,i_> end; |
| 75 | }; |
| 76 | |
| 77 | template<> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 78 | struct push_front_impl< aux::vector_tag<NDNBOOST_PP_DEC(i_)> > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 79 | { |
| 80 | template< typename Vector, typename T > struct apply |
| 81 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 82 | typedef NDNBOOST_PP_CAT(vector,i_)< |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 83 | T |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 84 | NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(i_)) |
| 85 | NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_DEC(i_), typename Vector::item) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 86 | > type; |
| 87 | }; |
| 88 | }; |
| 89 | |
| 90 | template<> |
| 91 | struct pop_front_impl< aux::vector_tag<i_> > |
| 92 | { |
| 93 | template< typename Vector > struct apply |
| 94 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 95 | typedef NDNBOOST_PP_CAT(vector,NDNBOOST_PP_DEC(i_))< |
| 96 | NDNBOOST_PP_ENUM_SHIFTED_PARAMS(i_, typename Vector::item) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 97 | > type; |
| 98 | }; |
| 99 | }; |
| 100 | |
| 101 | |
| 102 | template<> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 103 | struct push_back_impl< aux::vector_tag<NDNBOOST_PP_DEC(i_)> > |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 104 | { |
| 105 | template< typename Vector, typename T > struct apply |
| 106 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 107 | typedef NDNBOOST_PP_CAT(vector,i_)< |
| 108 | NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_DEC(i_), typename Vector::item) |
| 109 | NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(i_)) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 110 | T |
| 111 | > type; |
| 112 | }; |
| 113 | }; |
| 114 | |
| 115 | template<> |
| 116 | struct pop_back_impl< aux::vector_tag<i_> > |
| 117 | { |
| 118 | template< typename Vector > struct apply |
| 119 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 120 | typedef NDNBOOST_PP_CAT(vector,NDNBOOST_PP_DEC(i_))< |
| 121 | NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_DEC(i_), typename Vector::item) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 122 | > type; |
| 123 | }; |
| 124 | }; |
| 125 | |
| 126 | # endif // i_ > 0 |
| 127 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 128 | # if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ |
| 129 | && !defined(NDNBOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 130 | |
| 131 | template< typename V > |
| 132 | struct v_at<V,i_> |
| 133 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 134 | typedef typename V::NDNBOOST_PP_CAT(item,i_) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
| 137 | # else |
| 138 | |
| 139 | namespace aux { |
| 140 | template<> struct v_at_impl<i_> |
| 141 | { |
| 142 | template< typename V_ > struct result_ |
| 143 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 144 | typedef typename V_::NDNBOOST_PP_CAT(item,i_) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 145 | }; |
| 146 | }; |
| 147 | } |
| 148 | |
| 149 | template<> |
| 150 | struct at_impl< aux::vector_tag<i_> > |
| 151 | { |
| 152 | template< typename V_, typename N > struct apply |
| 153 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 154 | typedef typename aux::v_at_impl<NDNBOOST_MPL_AUX_VALUE_WKND(N)::value> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 155 | ::template result_<V_>::type type; |
| 156 | }; |
| 157 | }; |
| 158 | |
| 159 | #if i_ > 0 |
| 160 | template<> |
| 161 | struct front_impl< aux::vector_tag<i_> > |
| 162 | { |
| 163 | template< typename Vector > struct apply |
| 164 | { |
| 165 | typedef typename Vector::item0 type; |
| 166 | }; |
| 167 | }; |
| 168 | |
| 169 | template<> |
| 170 | struct back_impl< aux::vector_tag<i_> > |
| 171 | { |
| 172 | template< typename Vector > struct apply |
| 173 | { |
| 174 | typedef typename Vector::back type; |
| 175 | }; |
| 176 | }; |
| 177 | |
| 178 | template<> |
| 179 | struct empty_impl< aux::vector_tag<i_> > |
| 180 | { |
| 181 | template< typename Vector > struct apply |
| 182 | : false_ |
| 183 | { |
| 184 | }; |
| 185 | }; |
| 186 | #endif |
| 187 | |
| 188 | template<> |
| 189 | struct size_impl< aux::vector_tag<i_> > |
| 190 | { |
| 191 | template< typename Vector > struct apply |
| 192 | : long_<i_> |
| 193 | { |
| 194 | }; |
| 195 | }; |
| 196 | |
| 197 | template<> |
| 198 | struct O1_size_impl< aux::vector_tag<i_> > |
| 199 | : size_impl< aux::vector_tag<i_> > |
| 200 | { |
| 201 | }; |
| 202 | |
| 203 | template<> |
| 204 | struct clear_impl< aux::vector_tag<i_> > |
| 205 | { |
| 206 | template< typename Vector > struct apply |
| 207 | { |
| 208 | typedef vector0<> type; |
| 209 | }; |
| 210 | }; |
| 211 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 212 | # endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 213 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 214 | #endif // NDNBOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 215 | |
| 216 | #undef i_ |
| 217 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 218 | #endif // NDNBOOST_PP_IS_ITERATING |