pack.hpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file pack.hpp
  3. /// Contains helpers for pseudo-pack expansion.
  4. //
  5. // Copyright 2012 Eric Niebler. Distributed under the Boost
  6. // Software License, Version 1.0. (See accompanying file
  7. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_PROTO_TRANSFORM_DETAIL_PACK_HPP_EAN_2012_07_11
  9. #define BOOST_PROTO_TRANSFORM_DETAIL_PACK_HPP_EAN_2012_07_11
  10. #include <boost/preprocessor/cat.hpp>
  11. #include <boost/preprocessor/arithmetic/inc.hpp>
  12. #include <boost/preprocessor/arithmetic/dec.hpp>
  13. #include <boost/preprocessor/arithmetic/sub.hpp>
  14. #include <boost/preprocessor/punctuation/comma_if.hpp>
  15. #include <boost/preprocessor/repetition/enum.hpp>
  16. #include <boost/preprocessor/repetition/enum_params.hpp>
  17. #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
  18. #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
  19. #include <boost/preprocessor/repetition/repeat.hpp>
  20. #include <boost/preprocessor/iteration/local.hpp>
  21. #include <boost/preprocessor/iteration/iterate.hpp>
  22. #include <boost/mpl/bool.hpp>
  23. #include <boost/mpl/assert.hpp>
  24. #include <boost/type_traits/is_same.hpp>
  25. #include <boost/proto/proto_fwd.hpp>
  26. #if defined(_MSC_VER)
  27. # pragma warning(push)
  28. # pragma warning(disable: 4348) // redefinition of default parameter
  29. #endif
  30. namespace boost { namespace proto
  31. {
  32. namespace detail
  33. {
  34. template<typename Fun>
  35. struct msvc_fun_workaround;
  36. template<typename Tfx, typename T>
  37. struct expand_pattern_helper
  38. {
  39. typedef T type;
  40. typedef mpl::false_ applied;
  41. };
  42. template<typename Tfx, typename Fun>
  43. struct expand_pattern_helper<Tfx, Fun *>
  44. : expand_pattern_helper<Tfx, Fun>
  45. {};
  46. template<typename Tfx, typename T>
  47. struct expand_pattern_helper<Tfx, pack(T)>
  48. {
  49. // BUGBUG fix me. See comment in transform/detail/call.hpp
  50. BOOST_MPL_ASSERT_MSG(
  51. (is_same<T, _>::value)
  52. , PACK_EXPANSIONS_OF_EXPRESSIONS_OTHER_THAN_THE_CURRENT_NOT_YET_SUPPORTED
  53. , (T)
  54. );
  55. typedef Tfx type(T);
  56. typedef mpl::true_ applied;
  57. };
  58. template<typename Tfx>
  59. struct expand_pattern_helper<Tfx, pack(_)>
  60. {
  61. typedef Tfx type;
  62. typedef mpl::true_ applied;
  63. };
  64. #include <boost/proto/transform/detail/expand_pack.hpp>
  65. template<long Arity, typename Fun, typename Cont>
  66. struct expand_pattern;
  67. template<typename Fun, typename Cont>
  68. struct expand_pattern<0, Fun, Cont>
  69. : Cont::template cat<typename expand_pattern_helper<proto::_value, Fun>::type>
  70. {
  71. BOOST_MPL_ASSERT_MSG(
  72. (expand_pattern_helper<proto::_value, Fun>::applied::value)
  73. , NO_PACK_EXPRESSION_FOUND_IN_PACK_EXPANSION
  74. , (Fun)
  75. );
  76. };
  77. #include <boost/proto/transform/detail/pack_impl.hpp>
  78. }
  79. }}
  80. #if defined(_MSC_VER)
  81. # pragma warning(pop)
  82. #endif
  83. #endif