1 /*============================================================================= 2 Copyright (c) 2001-2010 Joel de Guzman 3 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 #include <boost/version.hpp> 8 9 // This is the same as the one in fusion in Boost 1.41. This is provided 10 // for compatibility with Boost 1.40 and below. 11 12 #if (BOOST_VERSION > 104000) 13 14 #include <boost/fusion/include/make_vector.hpp> 15 16 namespace boost { namespace spirit { namespace detail 17 { 18 namespace result_of 19 { 20 using fusion::result_of::make_vector; 21 } 22 using fusion::make_vector; 23 }}} 24 25 #else 26 27 #ifndef BOOST_PP_IS_ITERATING 28 #if !defined(SPIRIT_MAKE_VECTOR_07162005_0243) 29 #define SPIRIT_MAKE_VECTOR_07162005_0243 30 31 #include <boost/preprocessor/iterate.hpp> 32 #include <boost/preprocessor/repetition/enum_params.hpp> 33 #include <boost/preprocessor/repetition/enum_binary_params.hpp> 34 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp> 35 #include <boost/preprocessor/repetition/repeat_from_to.hpp> 36 #include <boost/fusion/container/vector/vector.hpp> 37 #include <boost/fusion/support/detail/as_fusion_element.hpp> 38 39 namespace boost { namespace fusion 40 { 41 struct void_; 42 }} 43 44 namespace boost { namespace spirit { namespace detail 45 { 46 namespace result_of 47 { 48 template < 49 BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT( 50 FUSION_MAX_VECTOR_SIZE, typename T, fusion::void_) 51 , typename Extra = fusion::void_ 52 > 53 struct make_vector; 54 55 template <> 56 struct make_vector<> 57 { 58 typedef fusion::vector0 type; 59 }; 60 } 61 62 inline fusion::vector0 make_vector()63 make_vector() 64 { 65 return fusion::vector0(); 66 } 67 68 #define BOOST_FUSION_AS_FUSION_ELEMENT(z, n, data) \ 69 typename fusion::detail::as_fusion_element<BOOST_PP_CAT(T, n)>::type 70 71 #define BOOST_PP_FILENAME_1 <boost/spirit/home/support/detail/make_vector.hpp> 72 #define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE) 73 #include BOOST_PP_ITERATE() 74 75 #undef BOOST_FUSION_AS_FUSION_ELEMENT 76 77 }}} 78 79 #endif 80 #else // defined(BOOST_PP_IS_ITERATING) 81 /////////////////////////////////////////////////////////////////////////////// 82 // 83 // Preprocessor vertical repetition code 84 // 85 /////////////////////////////////////////////////////////////////////////////// 86 87 #define N BOOST_PP_ITERATION() 88 89 namespace result_of 90 { 91 template <BOOST_PP_ENUM_PARAMS(N, typename T)> 92 #if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS) 93 #define TEXT(z, n, text) , text 94 struct make_vector< BOOST_PP_ENUM_PARAMS(N, T) BOOST_PP_REPEAT_FROM_TO(BOOST_PP_DEC(N), FUSION_MAX_VECTOR_SIZE, TEXT, fusion::void_) > 95 #undef TEXT 96 #else 97 struct make_vector<BOOST_PP_ENUM_PARAMS(N, T)> 98 #endif 99 { 100 typedef BOOST_PP_CAT(fusion::vector, N)<BOOST_PP_ENUM(N, BOOST_FUSION_AS_FUSION_ELEMENT, _)> type; 101 }; 102 } 103 104 template <BOOST_PP_ENUM_PARAMS(N, typename T)> BOOST_PP_CAT(fusion::vector,N)105 inline BOOST_PP_CAT(fusion::vector, N)<BOOST_PP_ENUM(N, BOOST_FUSION_AS_FUSION_ELEMENT, _)> 106 make_vector(BOOST_PP_ENUM_BINARY_PARAMS(N, T, const& _)) 107 { 108 return BOOST_PP_CAT(fusion::vector, N)<BOOST_PP_ENUM(N, BOOST_FUSION_AS_FUSION_ELEMENT, _)>( 109 BOOST_PP_ENUM_PARAMS(N, _)); 110 } 111 112 #undef N 113 #endif // defined(BOOST_PP_IS_ITERATING) 114 #endif // (BOOST_VERSION > 103800) 115