generate_by_value.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/detail/preprocessed/generate_by_value.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  5. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/generate_by_value.hpp")
  6. #endif
  7. ///////////////////////////////////////////////////////////////////////////////
  8. /// \file generate_by_value.hpp
  9. /// Contains definition of by_value_generator_\<\> class template.
  10. //
  11. // Copyright 2008 Eric Niebler. Distributed under the Boost
  12. // Software License, Version 1.0. (See accompanying file
  13. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  14. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  15. #pragma wave option(preserve: 1)
  16. #endif
  17. #define BOOST_PP_ITERATION_PARAMS_1 \
  18. (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/generate_by_value.hpp>))
  19. #include BOOST_PP_ITERATE()
  20. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  21. #pragma wave option(output: null)
  22. #endif
  23. #else // BOOST_PP_IS_ITERATING
  24. #define N BOOST_PP_ITERATION()
  25. template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Arg) >
  26. struct by_value_generator_<
  27. proto::expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, Arg)>, N>
  28. >
  29. {
  30. typedef
  31. BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, Arg)>
  32. src_args;
  33. typedef
  34. BOOST_PP_CAT(list, N)<
  35. BOOST_PP_ENUM_BINARY_PARAMS(N, typename uncvref<Arg, >::type BOOST_PP_INTERCEPT)
  36. >
  37. dst_args;
  38. typedef proto::expr<Tag, src_args, N> src_type;
  39. typedef proto::expr<Tag, dst_args, N> type;
  40. BOOST_FORCEINLINE
  41. static type const call(src_type const &e)
  42. {
  43. type that = {
  44. BOOST_PP_ENUM_PARAMS(N, e.child)
  45. };
  46. return that;
  47. }
  48. };
  49. template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename Arg) >
  50. struct by_value_generator_<
  51. proto::basic_expr<Tag, BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, Arg)>, N>
  52. >
  53. {
  54. typedef
  55. BOOST_PP_CAT(list, N)<BOOST_PP_ENUM_PARAMS(N, Arg)>
  56. src_args;
  57. typedef
  58. BOOST_PP_CAT(list, N)<
  59. BOOST_PP_ENUM_BINARY_PARAMS(N, typename uncvref<Arg, >::type BOOST_PP_INTERCEPT)
  60. >
  61. dst_args;
  62. typedef proto::basic_expr<Tag, src_args, N> src_type;
  63. typedef proto::basic_expr<Tag, dst_args, N> type;
  64. BOOST_FORCEINLINE
  65. static type const call(src_type const &e)
  66. {
  67. type that = {
  68. BOOST_PP_ENUM_PARAMS(N, e.child)
  69. };
  70. return that;
  71. }
  72. };
  73. #undef N
  74. #endif