frame.hpp 843 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // Copyright (c) 2024 Klemens Morgenstern (klemens.morgenstern@gmx.net)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_COBALT_EXPERIMENTAL_FRAME_HPP
  8. #define BOOST_COBALT_EXPERIMENTAL_FRAME_HPP
  9. #include <type_traits>
  10. #include <utility>
  11. namespace boost::cobalt::experimental
  12. {
  13. template<typename Impl, typename Promise>
  14. struct frame
  15. {
  16. void (*resume_) (frame *) = +[](frame * ff) { static_cast<Impl*>(ff)->resume();};
  17. void (*destroy_)(frame *) = +[](frame * ff) { static_cast<Impl*>(ff)->destroy();};
  18. typedef Promise promise_type;
  19. Promise promise;
  20. template<typename ... Args>
  21. frame(Args && ... args) : promise(std::forward<Args>(args)...)
  22. {
  23. }
  24. };
  25. }
  26. #endif //BOOST_COBALT_EXPERIMENTAL_FRAME_HPP