]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/v2/throw.cpp
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)
12 #include <boost/context/all.hpp>
15 boost::context::execution_context
< void > ctx
;
17 my_exception( boost::context::execution_context
< void > && ctx_
) :
18 ctx( std::forward
< boost::context::execution_context
< void > >( ctx_
) ) {
22 boost::context::execution_context
<void> f1(boost::context::execution_context
<void> ctx
) {
25 std::cout
<< "f1()" << std::endl
;
28 } catch ( my_exception
& e
) {
29 std::cout
<< "f1(): my_exception catched" << std::endl
;
30 ctx
= std::move( e
.ctx
);
35 boost::context::execution_context
<void> f2(boost::context::execution_context
<void> ctx
) {
36 throw my_exception( std::move( ctx
) );
41 boost::context::execution_context
< void > ctx( f1
);
44 ctx
= ctx( boost::context::exec_ontop_arg
, f2
);
46 std::cout
<< "main: done" << std::endl
;