Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
throwing Copyable versus throwing MoveOnly
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x64 #include <exception> #include <stdio.h> #include <typeinfo> struct Copyable { Copyable() { puts(" creating"); } Copyable(const Copyable&) { puts(" copying"); } ~Copyable() { puts(" destroying"); } }; struct MoveOnly { MoveOnly() { puts(" creating"); } MoveOnly(MoveOnly&&) { puts(" moving"); } ~MoveOnly() { puts(" destroying"); } }; using TYPE = Copyable; std::exception_ptr ex; int main() { try { printf("Throwing an exception of type %s...\n", typeid(TYPE).name()); throw TYPE(); } catch (...) { puts("Found the catch block."); puts("Now calling current_exception..."); ex = std::current_exception(); try { puts("Now calling rethrow_exception..."); std::rethrow_exception(ex); } catch (...) { puts("Found the next catch block."); } } puts("Now setting ex to nullptr..."); ex = nullptr; puts("Now exiting main()"); }
run
|
edit
|
history
|
help
0
10dan büyük mü küçük mü
5sdgts
Error defining lambda inside namespace
sample ptr and obj ex
Generic EventProvider
infix to postfix v 2.0
VS struct name enumerate
C++ exception
Hangman
3 sayinin toplami