fused_procedure.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_PROCEDURE_HPP_INCLUDED)
  8. #define BOOST_FUSION_FUNCTIONAL_ADAPTER_FUSED_PROCEDURE_HPP_INCLUDED
  9. #include <boost/type_traits/add_reference.hpp>
  10. #include <boost/config.hpp>
  11. #include <boost/fusion/functional/adapter/detail/access.hpp>
  12. #include <boost/fusion/functional/invocation/invoke_procedure.hpp>
  13. #if defined (BOOST_MSVC)
  14. # pragma warning(push)
  15. # pragma warning (disable: 4512) // assignment operator could not be generated.
  16. #endif
  17. namespace boost { namespace fusion
  18. {
  19. template <typename Function> class fused_procedure;
  20. //----- ---- --- -- - - - -
  21. template <typename Function>
  22. class fused_procedure
  23. {
  24. Function fnc_transformed;
  25. typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
  26. typedef typename detail::qf<Function>::type & func_fwd_t;
  27. public:
  28. inline explicit fused_procedure(func_const_fwd_t f = Function())
  29. : fnc_transformed(f)
  30. { }
  31. template <class Seq>
  32. inline void operator()(Seq const & s) const
  33. {
  34. fusion::invoke_procedure<
  35. func_const_fwd_t >(this->fnc_transformed,s);
  36. }
  37. template <class Seq>
  38. inline void operator()(Seq const & s)
  39. {
  40. fusion::invoke_procedure<
  41. func_fwd_t >(this->fnc_transformed,s);
  42. }
  43. template <class Seq>
  44. inline void operator()(Seq & s) const
  45. {
  46. fusion::invoke_procedure<
  47. func_const_fwd_t >(this->fnc_transformed,s);
  48. }
  49. template <class Seq>
  50. inline void operator()(Seq & s)
  51. {
  52. return fusion::invoke_procedure<
  53. func_fwd_t >(this->fnc_transformed,s);
  54. }
  55. typedef void result_type;
  56. };
  57. }}
  58. #if defined (BOOST_MSVC)
  59. # pragma warning(pop)
  60. #endif
  61. #endif