]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | |
b32b8144 | 2 | // Copyright Oliver Kowalke 2016. |
7c673cae FG |
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 | ||
b32b8144 | 10 | #include <boost/context/continuation.hpp> |
7c673cae FG |
11 | |
12 | namespace ctx = boost::context; | |
13 | ||
b32b8144 | 14 | ctx::continuation f1( ctx::continuation && c) { |
7c673cae | 15 | std::cout << "f1: entered first time" << std::endl; |
b32b8144 | 16 | c = c.resume(); |
7c673cae | 17 | std::cout << "f1: entered second time" << std::endl; |
b32b8144 | 18 | return std::move( c); |
7c673cae FG |
19 | } |
20 | ||
21 | int main() { | |
b32b8144 | 22 | ctx::continuation c = ctx::callcc( f1); |
7c673cae | 23 | std::cout << "f1: returned first time" << std::endl; |
b32b8144 | 24 | c = c.resume(); |
7c673cae | 25 | std::cout << "f1: returned second time" << std::endl; |
7c673cae | 26 | std::cout << "main: done" << std::endl; |
7c673cae FG |
27 | return EXIT_SUCCESS; |
28 | } |