August 2017
Intermediate to advanced
438 pages
14h 19m
English
All we need is to have an ability to store exceptions and pass them between threads just like a usual variable.
#include <boost/exception_ptr.hpp>struct process_exception { boost::exception_ptr exc_; explicit process_exception(const boost::exception_ptr& exc) : exc_(exc) {} void operator()() const;};
#include <boost/lexical_cast.hpp>void func_test2(); // Forward declaration.void process_exception::operator()() const { try { boost::rethrow_exception(exc_); } catch (const boost::bad_lexical_cast& /*e*/) { std::cout << "Lexical cast exception detected\n" << std::endl; // Pushing another ...Read now
Unlock full access