id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 5260,scope_guard safe_execute could support try/catch when BOOST_NO_EXCPTIONS not defined,z_gerg@…,Joaquín M López Muñoz,"Hi, Since I use boost library for many things, I thought I would take advantage of the scope guard implementation in boost/multi_index/detail/scope_guard.hpp. I know that is not standard practice, but thought it would be better then implementing my own ;-) However I discovered the hard way (got an unhandled exception) that safe_execute does not support try/catch. From the comments * - safe_execute does not feature a try-catch protection, so we can * use this even if BOOST_NO_EXCEPTIONS is defined. I verified that this is still the case in the latest release version. (I use an older version). It seems it could support try/catch while still honoring BOOST_NO_EXCEPTIONS when defined by wrapping the try and catch portions in #ifdefs as follows template static void safe_execute(J& j) { if(!j.dismissed_) #ifndef BOOST_NO_EXCEPTIONS try { #endif j.execute(); #ifndef BOOST_NO_EXCEPTIONS } catch (...) { } #endif } By doing that when using exceptions it will work as the original code this is based on works. And when BOOST_NO_EXCEPTIONS is defined it will work as it does now. The following example code will generate an unhandled exception with out the above mods. The same example with the above mods will also generate the unhandled exception if BOOST_NO_EXCEPTIONS is defined (you can uncomment the #define BOOST_NO_EXCEPTIONS to test that). It will not generate an unhandled exception when BOOST_NO_EXCEPTIONS is not defined. // #define BOOST_NO_EXCEPTIONS #include #include void bar() { throw std::exception(""testing""); } void foo() { boost::multi_index::detail::scope_guard barGuard = boost::multi_index::detail::make_guard(&bar); } int main(int argc, char* argv[]) { foo(); return 0; } ",Bugs,closed,To Be Determined,multi_index,Boost 1.46.0,Problem,fixed,,