Ticket #10764: main.cpp

File main.cpp, 533 bytes (added by jonathan.lilliemarck@…, 8 years ago)

Demonstrates a problem with current_exception_diagnostic_information.

Line 
1#include <boost/exception/all.hpp>
2#include <boost/throw_exception.hpp>
3
4int main() {
5 try {
6 BOOST_THROW_EXCEPTION(std::runtime_error(""));
7 }
8 catch (...) {
9 // Prints nothing
10 std::cout << "Exception: " << boost::current_exception_diagnostic_information() << std::endl;
11 }
12
13 try {
14 // Just add a space
15 BOOST_THROW_EXCEPTION(std::runtime_error(" "));
16 }
17 catch (...) {
18 // Now we error info is printed
19 std::cout << "Exception: " << boost::current_exception_diagnostic_information() << std::endl;
20 }
21}