fused.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_HPP_INCLUDED)
  8. #define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_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.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 <typename Function> class fused;
  21. //----- ---- --- -- - - - -
  22. template <typename Function>
  23. class fused
  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(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<func_const_fwd_t,Seq const>::type
  36. operator()(Seq const & s) const
  37. {
  38. return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
  39. }
  40. template <class Seq>
  41. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  42. inline typename result_of::invoke<func_fwd_t,Seq const>::type
  43. operator()(Seq const & s)
  44. {
  45. return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
  46. }
  47. template <class Seq>
  48. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  49. inline typename result_of::invoke<func_const_fwd_t,Seq>::type
  50. operator()(Seq & s) const
  51. {
  52. return fusion::invoke<func_const_fwd_t>(this->fnc_transformed,s);
  53. }
  54. template <class Seq>
  55. BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  56. inline typename result_of::invoke<func_fwd_t,Seq>::type
  57. operator()(Seq & s)
  58. {
  59. return fusion::invoke<func_fwd_t>(this->fnc_transformed,s);
  60. }
  61. template <typename Sig>
  62. struct result;
  63. template <class Self, class Seq>
  64. struct result< Self const (Seq) >
  65. : result_of::invoke<func_const_fwd_t,
  66. typename boost::remove_reference<Seq>::type >
  67. { };
  68. template <class Self, class Seq>
  69. struct result< Self(Seq) >
  70. : result_of::invoke<func_fwd_t,
  71. typename boost::remove_reference<Seq>::type >
  72. { };
  73. };
  74. }}
  75. #if defined (BOOST_MSVC)
  76. # pragma warning(pop)
  77. #endif
  78. #endif