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
virtual inheritance
Postfix side effect returning 2
not a parameter pack
du
make Derive final
VC++. G3log timestamp formatting.
It complies!
wrong up
PRIx64 on MSVC
VS2013 hello world includes