Imported Upstream version 1.71.0
[platform/upstream/boost.git] / libs / context / example / execution_context_v2 / jump_void.cpp
1
2 //          Copyright Oliver Kowalke 2014.
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/execution_context.hpp>
11
12 namespace ctx = boost::context;
13
14 ctx::execution_context< void > f1( ctx::execution_context< void > && ctxm) {
15     std::cout << "f1: entered first time" << std::endl;
16     ctxm = ctxm();
17     std::cout << "f1: entered second time" << std::endl;
18     return std::move( ctxm);
19 }
20
21 int main() {
22     ctx::execution_context< void > ctx1( f1);
23     ctx1 = ctx1();
24     std::cout << "f1: returned first time" << std::endl;
25     ctx1 = ctx1();
26     std::cout << "f1: returned second time" << std::endl;
27
28     std::cout << "main: done" << std::endl;
29
30     return EXIT_SUCCESS;
31 }