jump_void.cpp 802 B

12345678910111213141516171819202122232425262728
  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 <boost/context/continuation.hpp>
  8. namespace ctx = boost::context;
  9. ctx::continuation f1( ctx::continuation && c) {
  10. std::cout << "f1: entered first time" << std::endl;
  11. c = c.resume();
  12. std::cout << "f1: entered second time" << std::endl;
  13. return std::move( c);
  14. }
  15. int main() {
  16. ctx::continuation c = ctx::callcc( f1);
  17. std::cout << "f1: returned first time" << std::endl;
  18. c = c.resume();
  19. std::cout << "f1: returned second time" << std::endl;
  20. std::cout << "main: done" << std::endl;
  21. return EXIT_SUCCESS;
  22. }