#include #include #include #include typedef boost::error_info os_error_info_base; class os_error_info : public os_error_info_base { public: os_error_info(int const& err_code) : os_error_info_base(err_code) {} private: std::string value_as_string() const {return "Error code: " + boost::lexical_cast (value());} }; int main(int argc, char* argv[]) { try { throw boost::enable_error_info(std::exception("value_as_string test")) << os_error_info(10); } catch (boost::exception const& ex) { std::cerr << boost::diagnostic_information(ex) << std::endl; } // std::cin.get(); return 0; }