Chris@16: // -- Boost Lambda Library -- exceptions.hpp ---------------- Chris@16: // Chris@16: // Copyright (C) 2000 Gary Powell (gwpowell@hotmail.com) Chris@16: // Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi) Chris@16: // Chris@16: // Distributed under the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // For more information, see http://www.boost.org Chris@16: Chris@16: // ----------------------------------------------------- Chris@16: Chris@16: #if !defined(BOOST_LAMBDA_EXCEPTIONS_HPP) Chris@16: #define BOOST_LAMBDA_EXCEPTIONS_HPP Chris@16: Chris@16: #include "boost/lambda/core.hpp" Chris@16: #include "boost/lambda/detail/control_constructs_common.hpp" Chris@16: Chris@16: namespace boost { Chris@16: namespace lambda { Chris@16: Chris@16: typedef lambda_functor > placeholderE_type; Chris@16: Chris@16: namespace { Chris@16: boost::lambda::placeholderE_type freeE; Chris@16: boost::lambda::placeholderE_type& _e = freeE; Chris@16: } Chris@16: Chris@16: // -- exception related actions ------------------- Chris@16: Chris@16: // catch actions. Chris@16: template Chris@16: struct catch_action {}; Chris@16: Chris@16: struct catch_all_action {}; Chris@16: Chris@16: template Chris@16: struct return_try_catch_action {}; Chris@16: Chris@16: template Chris@16: struct try_catch_action {}; Chris@16: Chris@16: // rethrow actions Chris@16: struct throw_new_action {}; Chris@16: struct rethrow_action {}; Chris@16: Chris@16: template struct throw_action; Chris@16: Chris@16: template<> Chris@16: struct throw_action { Chris@16: template Chris@16: static RET apply() { Chris@16: throw; Chris@16: } Chris@16: }; Chris@16: Chris@16: template<> struct throw_action { Chris@16: template Chris@16: static RET apply(T& t) { Chris@16: throw t; Chris@16: } Chris@16: }; Chris@16: Chris@16: // return types for throw_actions -------------------------------------------- Chris@16: Chris@16: template Chris@16: struct Chris@16: return_type_N, Any> { Chris@16: typedef void type; Chris@16: }; Chris@16: Chris@16: Chris@16: // return types deductions ------------------------------------------------- Chris@16: Chris@16: // the return type of try_catch is the return type of the try lambda_functor Chris@16: // (the return types of try and catch parts must match unless try returns void Chris@16: // or the catch part throws for sure) Chris@16: Chris@16: // NOTE, the exception placeholder deduction rule is defined Chris@16: // in return_type_traits.hpp Chris@16: Chris@16: Chris@16: Chris@16: // defined in control_constructs Chris@16: class ifthenelse_action; Chris@16: Chris@16: namespace detail { Chris@16: Chris@16: // Templates for deducing, wether a lambda_functor throws inevitably of not - Chris@16: // This mechanism is needed to make the compiler happy about Chris@16: // return types of try and catch parts. Chris@16: Chris@16: // a lambda_functor throws for sure if: Chris@16: // - it is a throw expression Chris@16: // - it is a comma expression, and one of its arguments throws for sure Chris@16: // - it is an if_then_else expression and either the if statement or both Chris@16: // the then and else throw. Chris@16: // (there are other cases as well, but we do not cover them) Chris@16: // e.g. _1 + (rethrow(), 3) does throw for sure but this is not checked Chris@16: // This implies, that in such a case, the return types of try and catch parts Chris@16: // must match if the try part returns other than void. Chris@16: // (Such checks could be done though) Chris@16: Chris@16: template Chris@16: struct throws_for_sure_phase2 { Chris@16: static const bool value = false; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct throws_for_sure_phase2< Chris@16: lambda_functor< Chris@16: lambda_functor_base >, Args> Chris@16: > Chris@16: > Chris@16: { Chris@16: static const bool value = true; Chris@16: }; Chris@16: Chris@16: // Both then and else or the if throw of an if_then_else. Chris@16: template Chris@16: struct throws_for_sure_phase2< Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: ifthenelse_action, Args Chris@16: > Chris@16: > Chris@16: > Chris@16: { Chris@16: static const bool value = Chris@16: throws_for_sure_phase2< Chris@16: typename boost::tuples::element<0, Args>::type>::value Chris@16: || Chris@16: ( Chris@16: throws_for_sure_phase2< Chris@16: typename boost::tuples::element<1, Args>::type Chris@16: >::value Chris@16: && Chris@16: throws_for_sure_phase2< Chris@16: typename boost::tuples::element<2, Args>::type Chris@16: >::value Chris@16: ); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct throws_for_sure_phase2< Chris@16: lambda_functor< Chris@16: lambda_functor_base< other_action, Args> Chris@16: > Chris@16: > Chris@16: { Chris@16: static const bool value = Chris@16: throws_for_sure_phase2< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::value Chris@16: || Chris@16: throws_for_sure_phase2< Chris@16: typename boost::tuples::element<1, Args>::type Chris@16: >::value; Chris@16: }; Chris@16: Chris@16: // get rid of any qualifiers and references Chris@16: // lambda_functors should be stored like that, so this is to be extra sure Chris@16: template Chris@16: struct throws_for_sure { Chris@16: static const bool value Chris@16: = throws_for_sure_phase2< Chris@16: typename detail::remove_reference_and_cv::type Chris@16: >::value; Chris@16: }; Chris@16: Chris@16: Chris@16: // -- return_or_throw templates ----------------------------- Chris@16: Chris@16: // false case, catch and try return types are incompatible Chris@16: // Now the catch part must throw for sure, otherwise a compile time error Chris@16: // occurs. Chris@16: template Chris@16: struct return_or_throw_phase2 { Chris@16: template Chris@16: static RET call(Arg& arg, CALL_FORMAL_ARGS) { Chris@16: BOOST_STATIC_ASSERT(throws_for_sure::value); Chris@16: detail::select(arg, CALL_ACTUAL_ARGS); // this line throws Chris@16: throw 1; // this line is never performed, hence 1 is just a dummy Chris@16: // The line is needed to make compiler happy and not require Chris@16: // a matching return type Chris@16: } Chris@16: }; Chris@16: Chris@16: // the try and catch return types are compatible Chris@16: template<> Chris@16: struct return_or_throw_phase2 { Chris@16: template Chris@16: static RET call(Arg& arg, CALL_FORMAL_ARGS) { Chris@16: return detail::select(arg, CALL_ACTUAL_ARGS); Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: // the non-void case. Try part returns a value, so catch parts must Chris@16: // return a value of the same type or throw Chris@16: template Chris@16: struct return_or_throw { Chris@16: // Arg should be equal to ARG except that ARG may be a reference Chris@16: // to be sure, that there are no suprises for peculiarly defined return types Chris@16: // ARG is passed explicitely Chris@16: template Chris@16: static RET call(Arg& arg, CALL_FORMAL_ARGS) Chris@16: { Chris@16: // typedef typename Arg::return_type >::type RT; Chris@16: typedef typename as_lambda_functor::type lf_type; Chris@16: typedef typename lf_type::inherited::template Chris@16: sig >::type RT; Chris@16: Chris@16: return Chris@16: return_or_throw_phase2< Chris@16: ::boost::is_convertible::value Chris@16: >::template call(arg, CALL_ACTUAL_ARGS); Chris@16: } Chris@16: }; Chris@16: Chris@16: // if try part returns void, we do not return the catch parts either Chris@16: template Chris@16: struct return_or_throw { Chris@16: template Chris@16: static void call(Arg& arg, CALL_FORMAL_ARGS) { detail::select(arg, CALL_ACTUAL_ARGS); } Chris@16: }; Chris@16: Chris@16: } // end detail Chris@16: Chris@16: // Throwing exceptions --------------------------------------------- Chris@16: Chris@16: namespace detail { Chris@16: Chris@16: template struct catch_block {}; Chris@16: struct catch_all_block {}; Chris@16: Chris@16: template struct exception_catch_tag {}; Chris@16: Chris@16: // normal catch block is represented as Chris@16: // tagged_lambda_functor > >, LambdaFunctor> Chris@16: Chris@16: // the default catch all block as: Chris@16: // tagged_lambda_functor >, LambdaFunctor> Chris@16: Chris@16: Chris@16: } // end detail Chris@16: Chris@16: // the code is RETHROW, this ensures that a compile time error results, Chris@16: // if this lambda_functor is used outside a delayed catch_expression Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action<0, throw_action >, Chris@16: null_type Chris@16: > Chris@16: > Chris@16: rethrow() { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action<0, throw_action >, Chris@16: null_type Chris@16: > Chris@16: ( null_type() ); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action<1, throw_action >, Chris@16: tuple::type> Chris@16: > Chris@16: > Chris@16: throw_exception(const Arg1& a1) { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action<1, throw_action >, Chris@16: tuple::type> Chris@16: > Chris@16: ( tuple::type>(a1)); Chris@16: } Chris@16: Chris@16: // create catch blocks Chris@16: template Chris@16: inline const Chris@16: tagged_lambda_functor< Chris@16: detail::exception_catch_tag >, Chris@16: lambda_functor Chris@16: > Chris@16: catch_exception(const lambda_functor& a) { Chris@16: // the third placeholder cannot be used in catch_exception Chris@16: // BOOST_STATIC_ASSERT((!has_placeholder::value)); Chris@16: return Chris@16: tagged_lambda_functor< Chris@16: detail::exception_catch_tag >, Chris@16: lambda_functor Chris@16: > (a); Chris@16: } Chris@16: Chris@16: // catch and do nothing case. Chris@16: template Chris@16: inline const Chris@16: tagged_lambda_functor< Chris@16: detail::exception_catch_tag >, Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: do_nothing_action, Chris@16: null_type Chris@16: > Chris@16: > Chris@16: > Chris@16: catch_exception() { Chris@16: return Chris@16: tagged_lambda_functor< Chris@16: detail::exception_catch_tag >, Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: do_nothing_action, Chris@16: null_type Chris@16: > Chris@16: > Chris@16: > (); Chris@16: } Chris@16: Chris@16: // create catch(...) blocks Chris@16: template Chris@16: inline const Chris@16: tagged_lambda_functor< Chris@16: detail::exception_catch_tag, Chris@16: lambda_functor Chris@16: > Chris@16: catch_all(const lambda_functor& a) { Chris@16: // the third placeholder cannot be used in catch_exception Chris@16: BOOST_STATIC_ASSERT((!has_placeholder::value)); Chris@16: return Chris@16: tagged_lambda_functor< Chris@16: detail::exception_catch_tag, Chris@16: lambda_functor Chris@16: > (a); Chris@16: } Chris@16: Chris@16: // catch(...) and do nothing case. Chris@16: inline const Chris@16: tagged_lambda_functor< Chris@16: detail::exception_catch_tag, Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: do_nothing_action, Chris@16: null_type Chris@16: > Chris@16: > Chris@16: > Chris@16: catch_all() { Chris@16: return Chris@16: tagged_lambda_functor< Chris@16: detail::exception_catch_tag, Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: do_nothing_action, Chris@16: null_type Chris@16: > Chris@16: > Chris@16: > (); Chris@16: } Chris@16: Chris@16: // try_catch functions -------------------------------- Chris@16: // The second -> N argument(s) are must be catch lambda_functors Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action<2, try_catch_action > >, Chris@16: tuple, LF1> Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor, LF1>& a2) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action<2, try_catch_action > >, Chris@16: tuple, LF1> Chris@16: > Chris@16: ( tuple< lambda_functor, LF1>(a1, a2)); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action<3, try_catch_action, Catch2> > >, Chris@16: tuple, LF1, LF2> Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor >, LF1>& a2, Chris@16: const tagged_lambda_functor, LF2>& a3) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action<3, try_catch_action, Catch2> > >, Chris@16: tuple, LF1, LF2> Chris@16: > Chris@16: ( tuple, LF1, LF2>(a1, a2, a3)); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const lambda_functor< Chris@16: lambda_functor_base< Chris@16: action<4, try_catch_action, detail::catch_block, Catch3> > >, Chris@16: tuple, LF1, LF2, LF3> Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor >, LF1>& a2, Chris@16: const tagged_lambda_functor >, LF2>& a3, Chris@16: const tagged_lambda_functor, LF3>& a4) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action<4, try_catch_action, detail::catch_block, Catch3> > >, Chris@16: tuple, LF1, LF2, LF3> Chris@16: > Chris@16: ( tuple, LF1, LF2, LF3>(a1, a2, a3, a4)); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 5, Chris@16: try_catch_action< Chris@16: catch_action, detail::catch_block, detail::catch_block, Catch4> Chris@16: > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4> Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor >, LF1>& a2, Chris@16: const tagged_lambda_functor >, LF2>& a3, Chris@16: const tagged_lambda_functor >, LF3>& a4, Chris@16: const tagged_lambda_functor, LF4>& a5) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 5, Chris@16: try_catch_action, detail::catch_block, detail::catch_block, Catch4> > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4> Chris@16: > Chris@16: ( tuple, LF1, LF2, LF3, LF4>(a1, a2, a3, a4, a5)); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 6, Chris@16: try_catch_action, detail::catch_block, detail::catch_block, detail::catch_block, Catch5> > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4, LF5> Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor >, LF1>& a2, Chris@16: const tagged_lambda_functor >, LF2>& a3, Chris@16: const tagged_lambda_functor >, LF3>& a4, Chris@16: const tagged_lambda_functor >, LF4>& a5, Chris@16: const tagged_lambda_functor, LF5>& a6) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 6, Chris@16: try_catch_action< Chris@16: catch_action, detail::catch_block, detail::catch_block, detail::catch_block, Catch5> Chris@16: > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4, LF5> Chris@16: > Chris@16: ( tuple, LF1, LF2, LF3, LF4, LF5> Chris@16: (a1, a2, a3, a4, a5, a6) Chris@16: ); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 7, Chris@16: try_catch_action< Chris@16: catch_action, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Catch6> Chris@16: > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4, LF5, LF6> Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor >, LF1>& a2, Chris@16: const tagged_lambda_functor >, LF2>& a3, Chris@16: const tagged_lambda_functor >, LF3>& a4, Chris@16: const tagged_lambda_functor >, LF4>& a5, Chris@16: const tagged_lambda_functor >, LF5>& a6, Chris@16: const tagged_lambda_functor, LF6>& a7) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 7, Chris@16: try_catch_action< Chris@16: catch_action, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block,Catch6> Chris@16: > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4, LF5, LF6> Chris@16: > Chris@16: ( tuple, LF1, LF2, LF3, LF4, LF5, LF6> Chris@16: (a1, a2, a3, a4, a5, a6, a7)); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 8, Chris@16: try_catch_action< Chris@16: catch_action, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Catch7> Chris@16: > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4, LF5, LF6, LF7> Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor >, LF1>& a2, Chris@16: const tagged_lambda_functor >, LF2>& a3, Chris@16: const tagged_lambda_functor >, LF3>& a4, Chris@16: const tagged_lambda_functor >, LF4>& a5, Chris@16: const tagged_lambda_functor >, LF5>& a6, Chris@16: const tagged_lambda_functor >, LF6>& a7, Chris@16: const tagged_lambda_functor, LF7>& a8) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 8, Chris@16: try_catch_action< Chris@16: catch_action< Chris@16: detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Catch7 Chris@16: > Chris@16: > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4, LF5, LF6, LF7> Chris@16: > Chris@16: ( tuple, LF1, LF2, LF3, LF4, LF5, LF6, LF7> Chris@16: (a1, a2, a3, a4, a5, a6, a7, a8)); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 9, Chris@16: try_catch_action< Chris@16: catch_action< Chris@16: detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Catch8 Chris@16: > Chris@16: > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8> Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor >, LF1>& a2, Chris@16: const tagged_lambda_functor >, LF2>& a3, Chris@16: const tagged_lambda_functor >, LF3>& a4, Chris@16: const tagged_lambda_functor >, LF4>& a5, Chris@16: const tagged_lambda_functor >, LF5>& a6, Chris@16: const tagged_lambda_functor >, LF6>& a7, Chris@16: const tagged_lambda_functor >, LF7>& a8, Chris@16: const tagged_lambda_functor, LF8>& a9) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 9, Chris@16: try_catch_action< Chris@16: catch_action< Chris@16: detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Catch8 Chris@16: > Chris@16: > Chris@16: >, Chris@16: tuple, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8> Chris@16: > Chris@16: ( tuple, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8> Chris@16: (a1, a2, a3, a4, a5, a6, a7, a8, a9)); Chris@16: } Chris@16: Chris@16: template Chris@16: inline const Chris@16: lambda_functor< Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 10, Chris@16: try_catch_action< Chris@16: catch_action< Chris@16: detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Chris@16: Catch9 Chris@16: > Chris@16: > Chris@16: >, Chris@16: tuple< Chris@16: lambda_functor, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9 Chris@16: > Chris@16: > Chris@16: > Chris@16: try_catch( Chris@16: const lambda_functor& a1, Chris@16: const tagged_lambda_functor >, LF1>& a2, Chris@16: const tagged_lambda_functor >, LF2>& a3, Chris@16: const tagged_lambda_functor >, LF3>& a4, Chris@16: const tagged_lambda_functor >, LF4>& a5, Chris@16: const tagged_lambda_functor >, LF5>& a6, Chris@16: const tagged_lambda_functor >, LF6>& a7, Chris@16: const tagged_lambda_functor >, LF7>& a8, Chris@16: const tagged_lambda_functor >, LF8>& a9, Chris@16: const tagged_lambda_functor, LF9>& a10) Chris@16: { Chris@16: return Chris@16: lambda_functor_base< Chris@16: action< Chris@16: 10, Chris@16: try_catch_action< Chris@16: catch_action< Chris@16: detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Chris@16: Catch9 Chris@16: > Chris@16: > Chris@16: >, Chris@16: tuple< Chris@16: lambda_functor, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9 Chris@16: > Chris@16: > Chris@16: ( tuple< Chris@16: lambda_functor, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9 Chris@16: >(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)); Chris@16: } Chris@16: Chris@16: Chris@16: // --------------------------------------------------------------------------- Chris@16: // Specializations for lambda_functor_base of try_catch ---------------------- Chris@16: Chris@16: // 1 catch type case Chris@16: Chris@16: template Chris@16: class lambda_functor_base< Chris@16: action<2, try_catch_action > > >, Chris@16: Args Chris@16: > Chris@16: { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: // the return type of try_catch is the return type of the try lambda_functor Chris@16: // (the return types of try and catch parts must match unless try returns void Chris@16: // or the catch part throws for sure) Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: template Chris@16: class lambda_functor_base > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: // 2 catch types case Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block > > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class lambda_functor_base,detail::catch_all_block> > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: // 3 catch types case Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block > > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block,detail::catch_all_block> > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: // 4 catch types case Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block > > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block,detail::catch_all_block> > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: // 5 catch types case Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block > > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block,detail::catch_all_block> > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: // 6 catch types case Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block > > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch6& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block,detail::catch_all_block> > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: // 7 catch types case Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block > > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch6& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch7& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Chris@16: detail::catch_all_block> > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch6& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: // 8 catch types case Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Chris@16: detail::catch_block, detail::catch_block > > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch6& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch7& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch8& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<8>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Chris@16: detail::catch_block,detail::catch_all_block> > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch6& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch7& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<8>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: // 9 catch types case Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Chris@16: detail::catch_block, detail::catch_block, detail::catch_block > > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch6& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch7& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch8& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<8>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch9& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<9>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: class lambda_functor_base, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, detail::catch_block, Chris@16: detail::catch_block, detail::catch_block,detail::catch_all_block> > >, Args> { Chris@16: public: Chris@16: Args args; Chris@16: public: Chris@16: explicit lambda_functor_base(const Args& a) : args(a) {} Chris@16: Chris@16: template struct sig { Chris@16: typedef typename Chris@16: as_lambda_functor< Chris@16: typename boost::tuples::element<0, Args>::type Chris@16: >::type lf_type; Chris@16: Chris@16: typedef typename lf_type::inherited::template sig::type type; Chris@16: }; Chris@16: Chris@16: template Chris@16: RET call(CALL_FORMAL_ARGS) const { Chris@16: try Chris@16: { Chris@16: return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: catch (Catch1& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch2& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch3& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch4& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch5& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch6& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch7& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (Catch8& e) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<8>(args), CALL_ACTUAL_ARGS_NO_ENV, e); Chris@16: } Chris@16: catch (...) Chris@16: { Chris@16: return Chris@16: detail::return_or_throw::type> Chris@16: ::call(::boost::tuples::get<9>(args), CALL_ACTUAL_ARGS); Chris@16: } Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace lambda Chris@16: } // namespace boost Chris@16: Chris@16: Chris@16: #endif Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: