
Hello Jeremy! I'm not a metaprogramming expert, but I have one suggestion to imrove your implementation: replace static void execute(Iterator*, LastIterator*, F f) { typedef typename boost::mpl::deref<Iterator>::type item; try { throw; } //... } with static void execute(Iterator*, LastIterator*, F f) { assert(std::uncaught_exception()); typedef typename boost::mpl::deref<Iterator>::type item; try { throw; } //... } It prevents use of your catcher outside of any catch block. Actually, it is the first useful application of std::uncaught_exception() function that I'm aware of ;-) Now I'm more interested in the client side code - the visitor and code duplication here. It can be seen from another point - there is a coupling of exception handlers (operators in visitor) and types of exception that can be handled by catcher. We can have more freedom if client code would looks like this: //in application_exception_handler.hpp struct my_exception_handler { void operator()(std::string& sError); //Note here void operator()(std::exception& oError); void operator()(std::logic_error& oError); void operator()(void); }; //in application.cpp typedef boost::mpl::vector<std::logic_error, std::exception> exceptions; //Note here int main() try { throw std::logic_error("testing"); } catch(...) { catcher<exceptions>(my_exception_handler()); //Note here } with this transformation one can use one my_exception_handler class with many reduced exceptions typelists. It also eliminates the duplication problem. Duplication still exists but is intensional. Best, Oleg Abrosimov. Jeremy Day wrote:
Oleg,
I just uploaded catcher to the Boost Vault. You can find it (catcher.hpp) along with VS7 project files at http://tinyurl.com/l6lt4 . Any comments that you have (or anyone else, for that matter) are more than welcome.
Jeremy*
* _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost