1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include <iostream>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/empty.hpp>
using namespace boost::mpl;
template<typename v, bool empty>
struct error_handler_impl
{};
template<typename v>
struct error_handler_impl<v, false>
{
static void apply()
{
try {
throw;
} catch(front<v>::type const& e) {
std::cerr << "exception silencieuse " << e.what() << std::endl;
} catch(...) {
typedef typename pop_front<v>::type next;
typedef typename empty<next>::type empty;
error_handler_impl<next, empty::value>::apply();
}
}
};
template<typename v>
struct error_handler_impl<v, true>
{
static void apply()
{
throw;
}
};
template<typename v>
void error_handler()
{
typedef typename empty<v>::type empty;
error_handler_impl<v, empty::value>::apply();
} |
Partager