• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 //          Copyright Oliver Kowalke 2016.
3 // Distributed under the Boost Software License, Version 1.0.
4 //    (See accompanying file LICENSE_1_0.txt or copy at
5 //          http://www.boost.org/LICENSE_1_0.txt)
6 
7 #include <cstdlib>
8 #include <iostream>
9 
10 #include <boost/context/continuation.hpp>
11 
12 namespace ctx = boost::context;
13 
f1(ctx::continuation && c)14 ctx::continuation f1( ctx::continuation && c) {
15     std::cout << "f1: entered first time" << std::endl;
16     c = c.resume();
17     std::cout << "f1: entered second time" << std::endl;
18     return std::move( c);
19 }
20 
main()21 int main() {
22     ctx::continuation c = ctx::callcc( f1);
23     std::cout << "f1: returned first time" << std::endl;
24     c = c.resume();
25     std::cout << "f1: returned second time" << std::endl;
26     std::cout << "main: done" << std::endl;
27     return EXIT_SUCCESS;
28 }
29