]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/v2/parameter.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)
13 #include <boost/variant.hpp>
14 #include <boost/context/all.hpp>
15 #include <boost/lexical_cast.hpp>
17 typedef boost::variant
<int,std::string
> variant_t
;
19 namespace ctx
= boost::context
;
23 std::exception_ptr excptr_
;
24 ctx::execution_context
<variant_t
> ctx_
;
30 [this](ctx::execution_context
<variant_t
> ctx
, variant_t data
){
33 int i
= boost::get
<int>(data
);
34 data
= boost::lexical_cast
<std::string
>(i
);
35 auto result
= ctx( data
);
36 ctx
= std::move( std::get
<0>( result
) );
37 data
= std::get
<1>( result
);
39 } catch ( std::bad_cast
const&) {
40 excptr_
=std::current_exception();
46 std::string
operator()(int i
){
48 auto result
= ctx_( data
);
49 ctx_
= std::move( std::get
<0>( result
) );
50 data
= std::get
<1>( result
);
52 std::rethrow_exception(excptr_
);
54 return boost::get
<std::string
>(data
);
60 std::cout
<<x(7)<<std::endl
;
61 std::cout
<< "done" << std::endl
;