Run Code
|
API
|
Code Wall
|
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
!Enum
lab1
MSVC C++ runtime bug in dynamic_cast
Eight Queen
algorithm_1
derived_tempalte
MSVCStatic
Sum of numbers in a series using sum formular
std::function ambiguity vc++
zero size std::array parameter