fused_function_object.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_FUSED_FUNCTION_OBJECT_HPP_INCLUDED)
  8. #define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_FUNCTION_OBJECT_HPP_INCLUDED
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/type_traits/add_reference.hpp>
  11. #include <boost/config.hpp>
  12. #include <boost/fusion/functional/adapter/detail/access.hpp>
  13. #include <boost/fusion/functional/invocation/invoke_function_object.hpp>
  14. #if defined (BOOST_MSVC)
  15. # pragma warning(push)
  16. # pragma warning (disable: 4512) // assignment operator could not be generated.
  17. #endif
  18. namespace boost { namespace fusion
  19. {
  20. template <class Function> class fused_function_object;
  21. //----- ---- --- -- - - - -
  22. template <class Function>
  23. class fused_function_object
  24. {
  25. Function fnc_transformed;
  26. typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
  27. typedef typename detail::qf<Function>::type & func_fwd_t;
  28. public:
  29. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  30. inline explicit fused_function_object(func_const_fwd_t f = Function())
  31. : fnc_transformed(f)
  32. { }
  33. template <class Seq>
  34. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  35. inline typename result_of::invoke_function_object<func_const_fwd_t,
  36. Seq const>::type operator()(Seq const & s) const
  37. {
  38. return fusion::invoke_function_object<
  39. func_const_fwd_t >(this->fnc_transformed,s);
  40. }
  41. template <class Seq>
  42. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  43. inline typename result_of::invoke_function_object<func_fwd_t,
  44. Seq const>::type
  45. operator()(Seq const & s)
  46. {
  47. return fusion::invoke_function_object<
  48. func_fwd_t >(this->fnc_transformed,s);
  49. }
  50. template <class Seq>
  51. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  52. inline typename result_of::invoke_function_object<func_const_fwd_t,
  53. Seq>::type
  54. operator()(Seq & s) const
  55. {
  56. return fusion::invoke_function_object<
  57. func_const_fwd_t >(this->fnc_transformed,s);
  58. }
  59. template <class Seq>
  60. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  61. inline typename result_of::invoke_function_object<func_fwd_t,Seq>::type
  62. operator()(Seq & s)
  63. {
  64. return fusion::invoke_function_object<
  65. func_fwd_t >(this->fnc_transformed,s);
  66. }
  67. template <typename Sig>
  68. struct result;
  69. template <class Self, class Seq>
  70. struct result< Self const (Seq) >
  71. : result_of::invoke_function_object<func_const_fwd_t,
  72. typename boost::remove_reference<Seq>::type >
  73. { };
  74. template <class Self, class Seq>
  75. struct result< Self(Seq) >
  76. : result_of::invoke_function_object<func_fwd_t,
  77. typename boost::remove_reference<Seq>::type >
  78. { };
  79. };
  80. }}
  81. #if defined (BOOST_MSVC)
  82. # pragma warning(pop)
  83. #endif
  84. #endif