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)
13 #include <boost/context/execution_context.hpp>
15 namespace ctx = boost::context;
17 struct my_exception : public std::runtime_error {
18 my_exception( std::string const& what) :
19 std::runtime_error{ what } {
24 ctx::execution_context< void > ctx([](ctx::execution_context<void> && ctx) {
27 std::cout << "entered" << std::endl;
29 } catch ( ctx::ontop_error const& e) {
31 std::rethrow_if_nested( e);
32 } catch ( my_exception const& ex) {
33 std::cerr << "my_exception: " << ex.what() << std::endl;
35 return e.get_context< void >();
38 return std::move( ctx);
42 ctx = ctx( ctx::exec_ontop_arg, []() { throw my_exception("abc"); });
44 std::cout << "main: done" << std::endl;