setup.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright Oliver Kowalke 2009.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_COROUTINES_DETAIL_SETUP_H
  6. #define BOOST_COROUTINES_DETAIL_SETUP_H
  7. #include <boost/assert.hpp>
  8. #include <boost/config.hpp>
  9. #include <boost/move/move.hpp>
  10. #include <boost/type_traits/decay.hpp>
  11. #include <boost/type_traits/is_convertible.hpp>
  12. #include <boost/type_traits/is_same.hpp>
  13. #include <boost/coroutine/attributes.hpp>
  14. #include <boost/coroutine/detail/coroutine_context.hpp>
  15. #include <boost/coroutine/detail/flags.hpp>
  16. #ifdef BOOST_HAS_ABI_HEADERS
  17. # include BOOST_ABI_PREFIX
  18. #endif
  19. namespace boost {
  20. namespace coroutines {
  21. namespace detail {
  22. template< typename Fn >
  23. struct setup
  24. {
  25. struct dummy {};
  26. Fn fn;
  27. coroutine_context * caller;
  28. coroutine_context * callee;
  29. attributes attr;
  30. #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
  31. setup( Fn fn_,
  32. coroutine_context * caller_,
  33. coroutine_context * callee_,
  34. attributes const& attr_) :
  35. fn( boost::forward< Fn >( fn_) ),
  36. caller( caller_),
  37. callee( callee_),
  38. attr( attr_)
  39. {}
  40. #endif
  41. setup( BOOST_RV_REF( Fn) fn_,
  42. coroutine_context * caller_,
  43. coroutine_context * callee_,
  44. attributes const& attr_,
  45. typename disable_if<
  46. is_same< typename decay< Fn >::type, setup >,
  47. dummy*
  48. >::type = 0) :
  49. #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
  50. fn( fn_),
  51. #else
  52. fn( boost::forward< Fn >( fn_) ),
  53. #endif
  54. caller( caller_),
  55. callee( callee_),
  56. attr( attr_)
  57. {}
  58. };
  59. }}}
  60. #ifdef BOOST_HAS_ABI_HEADERS
  61. # include BOOST_ABI_SUFFIX
  62. #endif
  63. #endif // BOOST_COROUTINES_DETAIL_SETUP_H