fix doc example typo
[boost.git] / boost / fusion / container / vector / detail / vector_n_chooser.hpp
blob29248907dec01b5ecf563665310ada2417b08ae2
1 /*=============================================================================
2 Copyright (c) 2001-2006 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #ifndef BOOST_PP_IS_ITERATING
8 #if !defined(FUSION_VECTOR_N_CHOOSER_07072005_1248)
9 #define FUSION_VECTOR_N_CHOOSER_07072005_1248
11 #include <boost/fusion/container/vector/limits.hpp>
13 // include vector0..N where N is FUSION_MAX_VECTOR_SIZE
14 #include <boost/fusion/container/vector/vector10.hpp>
15 #if (FUSION_MAX_VECTOR_SIZE > 10)
16 #include <boost/fusion/container/vector/vector20.hpp>
17 #endif
18 #if (FUSION_MAX_VECTOR_SIZE > 20)
19 #include <boost/fusion/container/vector/vector30.hpp>
20 #endif
21 #if (FUSION_MAX_VECTOR_SIZE > 30)
22 #include <boost/fusion/container/vector/vector40.hpp>
23 #endif
24 #if (FUSION_MAX_VECTOR_SIZE > 40)
25 #include <boost/fusion/container/vector/vector50.hpp>
26 #endif
28 #include <boost/mpl/distance.hpp>
29 #include <boost/mpl/find.hpp>
30 #include <boost/mpl/begin_end.hpp>
31 #include <boost/preprocessor/cat.hpp>
32 #include <boost/preprocessor/repetition/enum_params.hpp>
34 namespace boost { namespace fusion
36 struct void_;
39 namespace boost { namespace fusion { namespace detail
41 template <int N>
42 struct get_vector_n;
44 template <>
45 struct get_vector_n<0>
47 template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
48 struct call
50 typedef vector0 type;
54 #define BOOST_PP_FILENAME_1 \
55 <boost/fusion/container/vector/detail/vector_n_chooser.hpp>
56 #define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE)
57 #include BOOST_PP_ITERATE()
59 template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
60 struct vector_n_chooser
62 typedef
63 mpl::BOOST_PP_CAT(vector, FUSION_MAX_VECTOR_SIZE)
64 <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)>
65 input;
67 typedef typename mpl::begin<input>::type begin;
68 typedef typename mpl::find<input, void_>::type end;
69 typedef typename mpl::distance<begin, end>::type size;
71 typedef typename get_vector_n<size::value>::template
72 call<BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, T)>::type
73 type;
75 }}}
77 #endif
79 ///////////////////////////////////////////////////////////////////////////////
81 // Preprocessor vertical repetition code
83 ///////////////////////////////////////////////////////////////////////////////
84 #else // defined(BOOST_PP_IS_ITERATING)
86 #define N BOOST_PP_ITERATION()
88 template <>
89 struct get_vector_n<N>
91 template <BOOST_PP_ENUM_PARAMS(FUSION_MAX_VECTOR_SIZE, typename T)>
92 struct call
94 typedef BOOST_PP_CAT(vector, N)<BOOST_PP_ENUM_PARAMS(N, T)> type;
98 #undef N
99 #endif // defined(BOOST_PP_IS_ITERATING)