blob: d256e314fcc1e624c6902cf75810e034a938b83a [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001
2// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
3
Jeff Thompson3d613fd2013-10-15 15:39:04 -07004#if defined(NDNBOOST_PP_IS_ITERATING)
Jeff Thompsona28eed82013-08-22 16:21:10 -07005
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 Thompson3d613fd2013-10-15 15:39:04 -070025#define i_ NDNBOOST_PP_FRAME_ITERATION(1)
Jeff Thompsona28eed82013-08-22 16:21:10 -070026
Jeff Thompson3d613fd2013-10-15 15:39:04 -070027#if defined(NDNBOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
Jeff Thompsona28eed82013-08-22 16:21:10 -070028
29# define AUX778076_VECTOR_TAIL(vector, i_, T) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070030 NDNBOOST_PP_CAT(vector,i_)< \
31 NDNBOOST_PP_ENUM_PARAMS(i_, T) \
Jeff Thompsona28eed82013-08-22 16:21:10 -070032 > \
33 /**/
34
35#if i_ > 0
36template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -070037 NDNBOOST_PP_ENUM_PARAMS(i_, typename T)
Jeff Thompsona28eed82013-08-22 16:21:10 -070038 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -070039struct NDNBOOST_PP_CAT(vector,i_)
Jeff Thompsona28eed82013-08-22 16:21:10 -070040 : v_item<
Jeff Thompson3d613fd2013-10-15 15:39:04 -070041 NDNBOOST_PP_CAT(T,NDNBOOST_PP_DEC(i_))
42 , AUX778076_VECTOR_TAIL(vector,NDNBOOST_PP_DEC(i_),T)
Jeff Thompsona28eed82013-08-22 16:21:10 -070043 >
44{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070045 typedef NDNBOOST_PP_CAT(vector,i_) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -070046};
47#endif
48
49# undef AUX778076_VECTOR_TAIL
50
51#else // "brute force" implementation
52
53# if i_ > 0
54
55template<
Jeff Thompson3d613fd2013-10-15 15:39:04 -070056 NDNBOOST_PP_ENUM_PARAMS(i_, typename T)
Jeff Thompsona28eed82013-08-22 16:21:10 -070057 >
Jeff Thompson3d613fd2013-10-15 15:39:04 -070058struct NDNBOOST_PP_CAT(vector,i_)
Jeff Thompsona28eed82013-08-22 16:21:10 -070059{
60 typedef aux::vector_tag<i_> tag;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070061 typedef NDNBOOST_PP_CAT(vector,i_) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -070062
63# define AUX778076_VECTOR_ITEM(unused, i_, unused2) \
Jeff Thompson3d613fd2013-10-15 15:39:04 -070064 typedef NDNBOOST_PP_CAT(T,i_) NDNBOOST_PP_CAT(item,i_); \
Jeff Thompsona28eed82013-08-22 16:21:10 -070065 /**/
66
Jeff Thompson3d613fd2013-10-15 15:39:04 -070067 NDNBOOST_PP_REPEAT(i_, AUX778076_VECTOR_ITEM, unused)
Jeff Thompsona28eed82013-08-22 16:21:10 -070068# undef AUX778076_VECTOR_ITEM
Jeff Thompson3d613fd2013-10-15 15:39:04 -070069 typedef void_ NDNBOOST_PP_CAT(item,i_);
70 typedef NDNBOOST_PP_CAT(T,NDNBOOST_PP_DEC(i_)) back;
Jeff Thompsona28eed82013-08-22 16:21:10 -070071
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
77template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070078struct push_front_impl< aux::vector_tag<NDNBOOST_PP_DEC(i_)> >
Jeff Thompsona28eed82013-08-22 16:21:10 -070079{
80 template< typename Vector, typename T > struct apply
81 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070082 typedef NDNBOOST_PP_CAT(vector,i_)<
Jeff Thompsona28eed82013-08-22 16:21:10 -070083 T
Jeff Thompson3d613fd2013-10-15 15:39:04 -070084 NDNBOOST_PP_COMMA_IF(NDNBOOST_PP_DEC(i_))
85 NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_DEC(i_), typename Vector::item)
Jeff Thompsona28eed82013-08-22 16:21:10 -070086 > type;
87 };
88};
89
90template<>
91struct pop_front_impl< aux::vector_tag<i_> >
92{
93 template< typename Vector > struct apply
94 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070095 typedef NDNBOOST_PP_CAT(vector,NDNBOOST_PP_DEC(i_))<
96 NDNBOOST_PP_ENUM_SHIFTED_PARAMS(i_, typename Vector::item)
Jeff Thompsona28eed82013-08-22 16:21:10 -070097 > type;
98 };
99};
100
101
102template<>
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700103struct push_back_impl< aux::vector_tag<NDNBOOST_PP_DEC(i_)> >
Jeff Thompsona28eed82013-08-22 16:21:10 -0700104{
105 template< typename Vector, typename T > struct apply
106 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700107 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 Thompsona28eed82013-08-22 16:21:10 -0700110 T
111 > type;
112 };
113};
114
115template<>
116struct pop_back_impl< aux::vector_tag<i_> >
117{
118 template< typename Vector > struct apply
119 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700120 typedef NDNBOOST_PP_CAT(vector,NDNBOOST_PP_DEC(i_))<
121 NDNBOOST_PP_ENUM_PARAMS(NDNBOOST_PP_DEC(i_), typename Vector::item)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700122 > type;
123 };
124};
125
126# endif // i_ > 0
127
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700128# if !defined(NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
129 && !defined(NDNBOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
Jeff Thompsona28eed82013-08-22 16:21:10 -0700130
131template< typename V >
132struct v_at<V,i_>
133{
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700134 typedef typename V::NDNBOOST_PP_CAT(item,i_) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -0700135};
136
137# else
138
139namespace aux {
140template<> struct v_at_impl<i_>
141{
142 template< typename V_ > struct result_
143 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700144 typedef typename V_::NDNBOOST_PP_CAT(item,i_) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -0700145 };
146};
147}
148
149template<>
150struct at_impl< aux::vector_tag<i_> >
151{
152 template< typename V_, typename N > struct apply
153 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700154 typedef typename aux::v_at_impl<NDNBOOST_MPL_AUX_VALUE_WKND(N)::value>
Jeff Thompsona28eed82013-08-22 16:21:10 -0700155 ::template result_<V_>::type type;
156 };
157};
158
159#if i_ > 0
160template<>
161struct front_impl< aux::vector_tag<i_> >
162{
163 template< typename Vector > struct apply
164 {
165 typedef typename Vector::item0 type;
166 };
167};
168
169template<>
170struct back_impl< aux::vector_tag<i_> >
171{
172 template< typename Vector > struct apply
173 {
174 typedef typename Vector::back type;
175 };
176};
177
178template<>
179struct empty_impl< aux::vector_tag<i_> >
180{
181 template< typename Vector > struct apply
182 : false_
183 {
184 };
185};
186#endif
187
188template<>
189struct size_impl< aux::vector_tag<i_> >
190{
191 template< typename Vector > struct apply
192 : long_<i_>
193 {
194 };
195};
196
197template<>
198struct O1_size_impl< aux::vector_tag<i_> >
199 : size_impl< aux::vector_tag<i_> >
200{
201};
202
203template<>
204struct clear_impl< aux::vector_tag<i_> >
205{
206 template< typename Vector > struct apply
207 {
208 typedef vector0<> type;
209 };
210};
211
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700212# endif // NDNBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
Jeff Thompsona28eed82013-08-22 16:21:10 -0700213
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700214#endif // NDNBOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
Jeff Thompsona28eed82013-08-22 16:21:10 -0700215
216#undef i_
217
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700218#endif // NDNBOOST_PP_IS_ITERATING