unfused.hpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*=============================================================================
  2. Copyright (c) 2006-2007 Tobias Schwinger
  3. Use modification and distribution are subject to the Boost Software
  4. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. ==============================================================================*/
  7. #if !defined(BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_HPP_INCLUDED)
  8. #if !defined(BOOST_PP_IS_ITERATING)
  9. #include <boost/preprocessor/cat.hpp>
  10. #include <boost/preprocessor/iteration/iterate.hpp>
  11. #include <boost/preprocessor/repetition/enum_params.hpp>
  12. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  13. #include <boost/preprocessor/facilities/intercept.hpp>
  14. #include <boost/utility/result_of.hpp>
  15. #include <boost/config.hpp>
  16. #include <boost/fusion/container/vector/vector.hpp>
  17. #include <boost/fusion/functional/adapter/limits.hpp>
  18. #include <boost/fusion/functional/adapter/detail/access.hpp>
  19. #if defined (BOOST_MSVC)
  20. # pragma warning(push)
  21. # pragma warning (disable: 4512) // assignment operator could not be generated.
  22. #endif
  23. namespace boost { namespace fusion
  24. {
  25. template <class Function, bool AllowNullary = true>
  26. class unfused;
  27. //----- ---- --- -- - - - -
  28. template <class Function>
  29. class unfused<Function,true>
  30. : public unfused<Function,false>
  31. {
  32. typedef typename detail::qf_c<Function>::type function_c;
  33. typedef typename detail::qf<Function>::type function;
  34. typedef typename detail::call_param<Function>::type func_const_fwd_t;
  35. public:
  36. using unfused<Function,false>::operator();
  37. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  38. inline explicit unfused(func_const_fwd_t f = function())
  39. : unfused<Function,false>(f)
  40. { }
  41. typedef typename boost::result_of<
  42. function_c(fusion::vector0<> &) >::type call_const_0_result;
  43. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  44. inline call_const_0_result operator()() const
  45. {
  46. fusion::vector0<> arg;
  47. return this->fnc_transformed(arg);
  48. }
  49. typedef typename boost::result_of<
  50. function(fusion::vector0<> &) >::type call_0_result;
  51. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  52. inline call_0_result operator()()
  53. {
  54. fusion::vector0<> arg;
  55. return this->fnc_transformed(arg);
  56. }
  57. };
  58. template <class Function> class unfused<Function,false>
  59. {
  60. protected:
  61. Function fnc_transformed;
  62. typedef typename detail::qf_c<Function>::type function_c;
  63. typedef typename detail::qf<Function>::type function;
  64. typedef typename detail::call_param<Function>::type func_const_fwd_t;
  65. public:
  66. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  67. inline explicit unfused(func_const_fwd_t f = function())
  68. : fnc_transformed(f)
  69. { }
  70. template <typename Sig>
  71. struct result;
  72. #define BOOST_PP_FILENAME_1 \
  73. <boost/fusion/functional/adapter/unfused.hpp>
  74. #define BOOST_PP_ITERATION_LIMITS \
  75. (1,BOOST_FUSION_UNFUSED_MAX_ARITY)
  76. #include BOOST_PP_ITERATE()
  77. };
  78. }}
  79. #if defined (BOOST_MSVC)
  80. # pragma warning(pop)
  81. #endif
  82. namespace boost
  83. {
  84. #if !defined(BOOST_RESULT_OF_USE_DECLTYPE) || defined(BOOST_NO_CXX11_DECLTYPE)
  85. template<class F>
  86. struct result_of< boost::fusion::unfused<F> const () >
  87. {
  88. typedef typename boost::fusion::unfused<F>::call_const_0_result type;
  89. };
  90. template<class F>
  91. struct result_of< boost::fusion::unfused<F>() >
  92. {
  93. typedef typename boost::fusion::unfused<F>::call_0_result type;
  94. };
  95. #endif
  96. template<class F>
  97. struct tr1_result_of< boost::fusion::unfused<F> const () >
  98. {
  99. typedef typename boost::fusion::unfused<F>::call_const_0_result type;
  100. };
  101. template<class F>
  102. struct tr1_result_of< boost::fusion::unfused<F>() >
  103. {
  104. typedef typename boost::fusion::unfused<F>::call_0_result type;
  105. };
  106. }
  107. #define BOOST_FUSION_FUNCTIONAL_ADAPTER_UNFUSED_HPP_INCLUDED
  108. #else // defined(BOOST_PP_IS_ITERATING)
  109. ////////////////////////////////////////////////////////////////////////////////
  110. //
  111. // Preprocessor vertical repetition code
  112. //
  113. ////////////////////////////////////////////////////////////////////////////////
  114. #define N BOOST_PP_ITERATION()
  115. template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
  116. struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) >
  117. : boost::result_of< function_c(
  118. BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
  119. typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
  120. { };
  121. template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
  122. struct result< Self(BOOST_PP_ENUM_PARAMS(N,T)) >
  123. : boost::result_of< function(
  124. BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
  125. typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
  126. { };
  127. template <BOOST_PP_ENUM_PARAMS(N,typename T)>
  128. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  129. inline typename boost::result_of<function_c(BOOST_PP_CAT(fusion::vector,N)
  130. <BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)> & )>::type
  131. operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const
  132. {
  133. BOOST_PP_CAT(fusion::vector,N)<
  134. BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT) >
  135. arg(BOOST_PP_ENUM_PARAMS(N,a));
  136. return this->fnc_transformed(arg);
  137. }
  138. template <BOOST_PP_ENUM_PARAMS(N,typename T)>
  139. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  140. inline typename boost::result_of<function(BOOST_PP_CAT(fusion::vector,N)
  141. <BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)> & )>::type
  142. operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a))
  143. {
  144. BOOST_PP_CAT(fusion::vector,N)<
  145. BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT) >
  146. arg(BOOST_PP_ENUM_PARAMS(N,a));
  147. return this->fnc_transformed(arg);
  148. }
  149. #undef N
  150. #endif // defined(BOOST_PP_IS_ITERATING)
  151. #endif