source: NonGTP/Boost/boost/mpl/vector/aux_/numbered.hpp @ 857

Revision 857, 5.0 KB checked in by igarcia, 18 years ago (diff)
Line 
1
2// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
3
4#if defined(BOOST_PP_IS_ITERATING)
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// $Source: /cvsroot/boost/boost/boost/mpl/vector/aux_/numbered.hpp,v $
15// $Date: 2004/09/02 15:41:19 $
16// $Revision: 1.8 $
17
18#include <boost/preprocessor/enum_params.hpp>
19#include <boost/preprocessor/enum_shifted_params.hpp>
20#include <boost/preprocessor/comma_if.hpp>
21#include <boost/preprocessor/repeat.hpp>
22#include <boost/preprocessor/dec.hpp>
23#include <boost/preprocessor/cat.hpp>
24
25#define i_ BOOST_PP_FRAME_ITERATION(1)
26
27#if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
28
29#   define AUX778076_VECTOR_TAIL(vector, i_, T) \
30    BOOST_PP_CAT(vector,i_)< \
31          BOOST_PP_ENUM_PARAMS(i_, T) \
32        > \
33    /**/
34
35#if i_ > 0
36template<
37      BOOST_PP_ENUM_PARAMS(i_, typename T)
38    >
39struct BOOST_PP_CAT(vector,i_)
40    : v_item<
41          BOOST_PP_CAT(T,BOOST_PP_DEC(i_))
42        , AUX778076_VECTOR_TAIL(vector,BOOST_PP_DEC(i_),T)
43        >
44{
45    typedef BOOST_PP_CAT(vector,i_) type;
46};
47#endif
48
49#   undef AUX778076_VECTOR_TAIL
50
51#else // "brute force" implementation
52
53#   if i_ > 0
54
55template<
56      BOOST_PP_ENUM_PARAMS(i_, typename T)
57    >
58struct BOOST_PP_CAT(vector,i_)
59{
60    typedef aux::vector_tag<i_> tag;
61    typedef BOOST_PP_CAT(vector,i_) type;
62
63#   define AUX778076_VECTOR_ITEM(unused, i_, unused2) \
64    typedef BOOST_PP_CAT(T,i_) BOOST_PP_CAT(item,i_); \
65    /**/
66
67    BOOST_PP_REPEAT(i_, AUX778076_VECTOR_ITEM, unused)
68#   undef AUX778076_VECTOR_ITEM
69    typedef void_ BOOST_PP_CAT(item,i_);
70    typedef BOOST_PP_CAT(T,BOOST_PP_DEC(i_)) back;
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
77template<>
78struct push_front_impl< aux::vector_tag<BOOST_PP_DEC(i_)> >
79{
80    template< typename Vector, typename T > struct apply
81    {
82        typedef BOOST_PP_CAT(vector,i_)<
83              T
84              BOOST_PP_COMMA_IF(BOOST_PP_DEC(i_))
85              BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(i_), typename Vector::item)
86            > type;
87    };
88};
89
90template<>
91struct pop_front_impl< aux::vector_tag<i_> >
92{
93    template< typename Vector > struct apply
94    {
95        typedef BOOST_PP_CAT(vector,BOOST_PP_DEC(i_))<
96              BOOST_PP_ENUM_SHIFTED_PARAMS(i_, typename Vector::item)
97            > type;
98    };
99};
100
101
102template<>
103struct push_back_impl< aux::vector_tag<BOOST_PP_DEC(i_)> >
104{
105    template< typename Vector, typename T > struct apply
106    {
107        typedef BOOST_PP_CAT(vector,i_)<
108              BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(i_), typename Vector::item)
109              BOOST_PP_COMMA_IF(BOOST_PP_DEC(i_))
110              T
111            > type;
112    };
113};
114
115template<>
116struct pop_back_impl< aux::vector_tag<i_> >
117{
118    template< typename Vector > struct apply
119    {
120        typedef BOOST_PP_CAT(vector,BOOST_PP_DEC(i_))<
121              BOOST_PP_ENUM_PARAMS(BOOST_PP_DEC(i_), typename Vector::item)
122            > type;
123    };
124};
125
126#   endif // i_ > 0
127
128#   if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
129    && !defined(BOOST_MPL_CFG_NO_NONTYPE_TEMPLATE_PARTIAL_SPEC)
130
131template< typename V >
132struct v_at<V,i_>
133{
134    typedef typename V::BOOST_PP_CAT(item,i_) type;
135};
136
137#   else
138
139namespace aux {
140template<> struct v_at_impl<i_>
141{
142    template< typename V_ > struct result_
143    {
144        typedef typename V_::BOOST_PP_CAT(item,i_) type;
145    };
146};
147}
148
149template<>
150struct at_impl< aux::vector_tag<i_> >
151{
152    template< typename V_, typename N > struct apply
153    {
154        typedef typename aux::v_at_impl<BOOST_MPL_AUX_VALUE_WKND(N)::value>
155            ::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
212#   endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
213
214#endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
215
216#undef i_
217
218#endif // BOOST_PP_IS_ITERATING
Note: See TracBrowser for help on using the repository browser.