zip.hpp 4.2 KB

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