Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
std::current_exception makes a copy
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <exception> #include <stdio.h> struct Widget { Widget() { puts("constructing the exception object of type Widget on the stack"); } Widget(const Widget&) { puts("copying the Widget object from the stack to the heap"); } ~Widget() { puts("destroying a Widget object"); } }; std::exception_ptr ex; void bar() { puts("Now throwing Widget..."); throw Widget(); } void foo() { try { bar(); } catch (...) { puts("Found the catch handler."); puts("Now calling current_exception..."); ex = std::current_exception(); } } int main() { foo(); puts("Now setting ex to nullptr..."); ex = nullptr; puts("Now exiting main()"); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Arrays
PreprocessorVsNamespace
Multi Inheritance
c++ pure apstraction
Generic EventProvider
Thing
My Window
upper_bound With binary_function Visual Studio 2008 Bug?
Title
success
Please log in to post a comment.