Skip to content

Commit b6de0db

Browse files
authored
Update 003_exception_std_make_exception_ptr.cpp
1 parent 127cbb8 commit b6de0db

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
1
1+
// make_exception_ptr example
2+
#include <iostream> // std::cout
3+
#include <exception> // std::make_exception_ptr, std::rethrow_exception
4+
#include <stdexcept> // std::logic_error
5+
6+
int main () {
7+
auto p = std::make_exception_ptr(std::logic_error("logic_error"));
8+
9+
try {
10+
std::rethrow_exception (p);
11+
} catch (const std::exception& e) {
12+
std::cout << "exception caught: " << e.what() << '\n';
13+
}
14+
return 0;
15+
}

0 commit comments

Comments
 (0)