]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/context/example/v1/parameter.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / context / example / v1 / parameter.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 <exception>
9 #include <iostream>
10 #include <memory>
11 #include <string>
12
13 #include <boost/context/all.hpp>
14 #include <boost/lexical_cast.hpp>
15
16 class X{
17 private:
18 std::exception_ptr excptr_;
19 boost::context::execution_context caller_;
20 boost::context::execution_context callee_;
21
22 public:
23 X():
24 excptr_(),
25 caller_(boost::context::execution_context::current()),
26 callee_( [this]( void * vp){
27 try {
28 int i = * static_cast< int * >( vp);
29 std::string str = boost::lexical_cast<std::string>(i);
30 caller_( & str);
31 } catch ( std::bad_cast const&) {
32 excptr_=std::current_exception();
33 }
34 })
35 {}
36
37 std::string operator()(int i){
38 void * ret = callee_( & i);
39 if(excptr_){
40 std::rethrow_exception(excptr_);
41 }
42 return * static_cast< std::string * >( ret);
43 }
44 };
45
46 int main() {
47 X x;
48 std::cout<<x(7)<<std::endl;
49 std::cout << "done" << std::endl;
50 return EXIT_SUCCESS;
51 }