Can't repro on godbolt/gcc: https://godbolt.org/z/rWddT5xce. I know you're using MSVC but please provide compiler version and Boost version. On Sun, Oct 29, 2023 at 7:29 AM Bernard via Boost-users < boost-users@lists.boost.org> wrote:
greetings kind regards may i please inquire how not to obtain "std::exception::what: Unknown exception" from diagnosic_inforumation() . my meaning is to inquire how to obtain as per example on boost web page https://www.boost.org/doc/libs/1_83_0/libs/exception/doc/tutorial_diagnostic... output : "std::exception::what: example_io error" id est where did "example_io error" come from as neither boost::exception nor std:::exception accept constructor string arguments .
please my code below . thank you kindly
#include "stl" // #includes all stl #include files #include "boost\exception\all.hpp" using namespace std;
struct ceXception : virtual boost::exception, virtual std::exception { using this_type = ceXception; ceXception() {} auto what() { cerr << __FUNCSIG__ << endl; return string("return from " + string(__FUNCSIG__)); } template<typename charType> friend std::basic_ostream<charType>& operator<<(std::basic_ostream<charType>& _ostream, const this_type&) { cerr << "to cerr from " << __FUNCSIG__ << endl; _ostream << "to ostream from " << __FUNCSIG__ << endl; return _ostream; } };
void foo() { try { BOOST_THROW_EXCEPTION(ceXception()); } catch (ceXception& e) { cerr << boost::diagnostic_information(e); } }
int main() { foo(); return 0; } _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users