Last active
August 14, 2025 19:18
-
-
Save Peter0x44/3efd03adcc56101395d9488ffb5d6c6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >cl test.cpp | |
| Microsoft (R) C/C++ Optimizing Compiler Version 19.43.34809 for x64 | |
| Copyright (C) Microsoft Corporation. All rights reserved. | |
| test.cpp | |
| test.cpp(12): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc | |
| Microsoft (R) Incremental Linker Version 14.43.34809.0 | |
| Copyright (C) Microsoft Corporation. All rights reserved. | |
| /out:test.exe | |
| test.obj | |
| >test.exe | |
| Default ctor | |
| Inside catch | |
| Copy ctor | |
| Created exception_ptr | |
| Default ctor | |
| Copy ctor | |
| Caught lvalue exception | |
| Copy ctor | |
| Default ctor | |
| Copy ctor | |
| Copy ctor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <exception> | |
| struct MyException { | |
| MyException() { std::cout << "Default ctor\n"; } | |
| MyException(const MyException&) { std::cout << "Copy ctor\n"; } | |
| MyException(MyException&&) noexcept { std::cout << "Move ctor\n"; } | |
| }; | |
| int main() { | |
| try { | |
| throw MyException(); | |
| } catch(...) { | |
| std::cout << "Inside catch\n"; | |
| std::exception_ptr eptr = std::current_exception(); | |
| std::cout << "Created exception_ptr\n"; | |
| } | |
| MyException e; | |
| try { | |
| throw e; | |
| } catch(...) { | |
| std::cout << "Caught lvalue exception\n"; | |
| std::exception_ptr eptr = std::current_exception(); | |
| } | |
| MyException obj; | |
| std::exception_ptr eptr2 = std::make_exception_ptr(obj); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment