Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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

5,820 views

Published on

Published in: Technology, Education
  • Dating for everyone is here: ❶❶❶ http://bit.ly/2Q98JRS ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❶❶❶ http://bit.ly/2Q98JRS ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

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

×