zip.hpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2006 Dan Marsden
  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_ZIP_HPP_20060125_2058)
  9. #define FUSION_ZIP_HPP_20060125_2058
  10. #include <boost/fusion/view/zip_view.hpp>
  11. #include <boost/fusion/adapted/mpl.hpp>
  12. #include <boost/fusion/container/vector.hpp>
  13. #include <boost/fusion/container/vector/convert.hpp>
  14. #include <boost/fusion/support/detail/pp_round.hpp>
  15. #include <boost/type_traits/add_reference.hpp>
  16. #include <boost/preprocessor/repetition/enum.hpp>
  17. #include <boost/preprocessor/repetition/enum_params.hpp>
  18. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  19. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  20. #include <boost/preprocessor/arithmetic/inc.hpp>
  21. #include <boost/preprocessor/iteration/iterate.hpp>
  22. #include <boost/mpl/vector.hpp>
  23. #include <boost/mpl/transform.hpp>
  24. #include <boost/mpl/placeholders.hpp>
  25. #if !defined(FUSION_MAX_ZIP_SEQUENCES)
  26. #define FUSION_MAX_ZIP_SEQUENCES 10
  27. #endif
  28. #define FUSION_MAX_ZIP_SEQUENCES_STR BOOST_PP_STRINGIZE(BOOST_FUSION_PP_ROUND_UP(FUSION_MAX_ZIP_SEQUENCES))
  29. #if !defined(BOOST_FUSION_DONT_USE_PREPROCESSED_FILES)
  30. #include <boost/fusion/algorithm/transformation/detail/preprocessed/zip.hpp>
  31. #else
  32. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  33. #pragma wave option(preserve: 2, line: 0, output: "detail/preprocessed/zip" FUSION_MAX_ZIP_SEQUENCES_STR ".hpp")
  34. #endif
  35. /*=============================================================================
  36. Copyright (c) 2001-2011 Joel de Guzman
  37. Copyright (c) 2006 Dan Marsden
  38. Distributed under the Boost Software License, Version 1.0. (See accompanying
  39. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  40. This is an auto-generated file. Do not edit!
  41. ==============================================================================*/
  42. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  43. #pragma wave option(preserve: 1)
  44. #endif
  45. namespace boost { namespace fusion
  46. {
  47. struct void_;
  48. namespace result_of
  49. {
  50. template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_INC(FUSION_MAX_ZIP_SEQUENCES), typename T, fusion::void_)>
  51. struct zip;
  52. }
  53. #define BOOST_PP_FILENAME_1 \
  54. <boost/fusion/algorithm/transformation/zip.hpp>
  55. #define BOOST_PP_ITERATION_LIMITS (2, FUSION_MAX_ZIP_SEQUENCES)
  56. #include BOOST_PP_ITERATE()
  57. }}
  58. #if defined(__WAVE__) && defined(BOOST_FUSION_CREATE_PREPROCESSED_FILES)
  59. #pragma wave option(output: null)
  60. #endif
  61. #endif // BOOST_FUSION_DONT_USE_PREPROCESSED_FILES
  62. #endif
  63. #else
  64. #define ZIP_ITERATION BOOST_PP_ITERATION()
  65. namespace result_of
  66. {
  67. template< BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, typename T) >
  68. #if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS)
  69. #define TEXT(z, n, text) , text
  70. struct zip< BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, T) BOOST_PP_REPEAT_FROM_TO(BOOST_PP_DEC(ZIP_ITERATION), FUSION_MAX_ZIP_SEQUENCES, TEXT, void_) >
  71. #undef TEXT
  72. #else
  73. struct zip< BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, T) >
  74. #endif
  75. {
  76. typedef mpl::vector< BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, T) > sequences;
  77. typedef typename mpl::transform<sequences, add_reference<mpl::_> >::type ref_params;
  78. typedef zip_view<typename result_of::as_vector<ref_params>::type> type;
  79. };
  80. }
  81. #define FUSION_REF_PARAM(z, n, data) const T ## n&
  82. template<BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, typename T)>
  83. inline typename result_of::zip<BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, const T)>::type
  84. zip(BOOST_PP_ENUM_BINARY_PARAMS(ZIP_ITERATION, T, const& t))
  85. {
  86. fusion::vector<BOOST_PP_ENUM(ZIP_ITERATION, FUSION_REF_PARAM, _)> seqs(
  87. BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, t));
  88. return typename result_of::zip<BOOST_PP_ENUM_PARAMS(ZIP_ITERATION, const T)>::type(
  89. seqs);
  90. }
  91. #undef FUSION_REF_PARAM
  92. #undef ZIP_ITERATION
  93. #endif