exception_ptr in エラーハンドリング勉強会

5,128 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
5,128
On SlideShare
0
From Embeds
0
Number of Embeds
3,597
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

exception_ptr in エラーハンドリング勉強会

  1. 1. exception_ptrH.23/09/04Egtra
  2. 2. イントロint main() { int result; std::thread t(f, ref(result)); // …… t.join(); cout << result << endl;}
  3. 3. イントロvoid f(int& result) { try { 作業 } catch (...) { // どうする? }}
  4. 4. 案1void f(int& result) { try { } catch (std::exception const& e) { cerr << e.what() << endl; }}
  5. 5. 案2void f(int& result, std::exception& re) { try { } catch (std::exception const& e) { re = e; }}
  6. 6. 案2int result; exception e;std::thread t(f, ref(result), ref(e));t.join();cerr << e.what() << endl;
  7. 7. 案3 exception_ptrvoid f(int& result, exception_ptr& re) { try { } catch (...) { re = current_exception(); }}
  8. 8. 案3 exception_ptrint result; exception_ptr e;thread t(f, ref(result), ref(e));t.join();try {rethrow_exception(e);}catch (std::exception const& e) {...}
  9. 9. 案3 exception_ptrint result; exception_ptr e;thread t(f, ref(result), ref(e));t.join();try {rethrow_exception(e);}catch (std::exception const& e) {...}catch (MyException const& e) {...}
  10. 10. それ、<future>で• 参考: – http://d.hatena.ne.jp/melpon/ 20081205/1228482683

×