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/all.hpp>
14 #include <boost/lexical_cast.hpp>
18 std::exception_ptr excptr_
;
19 boost::context::execution_context caller_
;
20 boost::context::execution_context callee_
;
25 caller_(boost::context::execution_context::current()),
26 callee_( [this]( void * vp
){
28 int i
= * static_cast< int * >( vp
);
29 std::string str
= boost::lexical_cast
<std::string
>(i
);
31 } catch ( std::bad_cast
const&) {
32 excptr_
=std::current_exception();
37 std::string
operator()(int i
){
38 void * ret
= callee_( & i
);
40 std::rethrow_exception(excptr_
);
42 return * static_cast< std::string
* >( ret
);
48 std::cout
<<x(7)<<std::endl
;
49 std::cout
<< "done" << std::endl
;