ontop_void.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright Oliver Kowalke 2016.
  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. #include <cstdlib>
  6. #include <iostream>
  7. #include <tuple>
  8. #include <boost/context/continuation.hpp>
  9. namespace ctx = boost::context;
  10. ctx::continuation f1( ctx::continuation && c) {
  11. std::cout << "f1: entered first time" << std::endl;
  12. c = c.resume();
  13. std::cout << "f1: entered second time" << std::endl;
  14. c = c.resume();
  15. std::cout << "f1: entered third time" << std::endl;
  16. return std::move( c);
  17. }
  18. ctx::continuation f2( ctx::continuation && c) {
  19. std::cout << "f2: entered" << std::endl;
  20. return std::move( c);
  21. }
  22. int main() {
  23. ctx::continuation c = ctx::callcc( f1);
  24. std::cout << "f1: returned first time" << std::endl;
  25. c = c.resume();
  26. std::cout << "f1: returned second time" << std::endl;
  27. c = c.resume_with( f2);
  28. std::cout << "f1: returned third time" << std::endl;
  29. std::cout << "main: done" << std::endl;
  30. return EXIT_SUCCESS;
  31. }