1// -- Boost Lambda Library -- exceptions.hpp ----------------
2//
3// Copyright (C) 2000 Gary Powell (gwpowell@hotmail.com)
4// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
5//
6// Distributed under the Boost Software License, Version 1.0. (See
7// accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9//
10// For more information, see http://www.boost.org
11
12// -----------------------------------------------------
13
14#if !defined(BOOST_LAMBDA_EXCEPTIONS_HPP)
15#define BOOST_LAMBDA_EXCEPTIONS_HPP
16
17#include "boost/lambda/core.hpp"
18#include "boost/lambda/detail/control_constructs_common.hpp"
19
20namespace boost {
21namespace lambda {
22
23typedef lambda_functor<placeholder<EXCEPTION> > placeholderE_type;
24
25namespace {
26 boost::lambda::placeholderE_type freeE;
27 boost::lambda::placeholderE_type& _e = freeE;
28}
29
30// -- exception related actions -------------------
31
32// catch actions.
33template <class Catch1, class Catch2 = null_type, class Catch3 = null_type,
34 class Catch4 = null_type, class Catch5 = null_type,
35 class Catch6 = null_type, class Catch7 = null_type,
36 class Catch8 = null_type, class Catch9 = null_type,
37 class Catch10 = null_type>
38struct catch_action {};
39
40struct catch_all_action {};
41
42template<class CatchActions>
43struct return_try_catch_action {};
44
45template<class CatchActions>
46struct try_catch_action {};
47
48// rethrow actions
49struct throw_new_action {};
50struct rethrow_action {};
51
52template<class ThrowType> struct throw_action;
53
54template<>
55struct throw_action<rethrow_action> {
56 template<class RET>
57 static RET apply() {
58 throw;
59 }
60};
61
62template<> struct throw_action<throw_new_action> {
63 template<class RET, class T>
64 static RET apply(T& t) {
65 throw t;
66 }
67};
68
69// return types for throw_actions --------------------------------------------
70
71template<class T, class Any>
72struct
73return_type_N<throw_action<T>, Any> {
74 typedef void type;
75};
76
77
78// return types deductions -------------------------------------------------
79
80// the return type of try_catch is the return type of the try lambda_functor
81// (the return types of try and catch parts must match unless try returns void
82// or the catch part throws for sure)
83
84// NOTE, the exception placeholder deduction rule is defined
85// in return_type_traits.hpp
86
87
88
89// defined in control_constructs
90class ifthenelse_action;
91
92namespace detail {
93
94// Templates for deducing, wether a lambda_functor throws inevitably of not -
95// This mechanism is needed to make the compiler happy about
96// return types of try and catch parts.
97
98// a lambda_functor throws for sure if:
99// - it is a throw expression
100// - it is a comma expression, and one of its arguments throws for sure
101// - it is an if_then_else expression and either the if statement or both
102// the then and else throw.
103// (there are other cases as well, but we do not cover them)
104// e.g. _1 + (rethrow(), 3) does throw for sure but this is not checked
105// This implies, that in such a case, the return types of try and catch parts
106// must match if the try part returns other than void.
107// (Such checks could be done though)
108
109template <class Arg>
110struct throws_for_sure_phase2 {
111 static const bool value = false;
112};
113
114template <int N, class ThrowType, class Args>
115struct throws_for_sure_phase2<
116 lambda_functor<
117 lambda_functor_base<action<N, throw_action<ThrowType> >, Args>
118 >
119>
120{
121 static const bool value = true;
122};
123
124// Both then and else or the if throw of an if_then_else.
125template <class Args>
126struct throws_for_sure_phase2<
127 lambda_functor<
128 lambda_functor_base<
129 ifthenelse_action, Args
130 >
131 >
132>
133{
134 static const bool value =
135 throws_for_sure_phase2<
136 typename boost::tuples::element<0, Args>::type>::value
137 ||
138 (
139 throws_for_sure_phase2<
140 typename boost::tuples::element<1, Args>::type
141 >::value
142 &&
143 throws_for_sure_phase2<
144 typename boost::tuples::element<2, Args>::type
145 >::value
146 );
147};
148
149template <class Args>
150struct throws_for_sure_phase2<
151 lambda_functor<
152 lambda_functor_base< other_action<comma_action>, Args>
153 >
154>
155{
156 static const bool value =
157 throws_for_sure_phase2<
158 typename boost::tuples::element<0, Args>::type
159 >::value
160 ||
161 throws_for_sure_phase2<
162 typename boost::tuples::element<1, Args>::type
163 >::value;
164};
165
166 // get rid of any qualifiers and references
167 // lambda_functors should be stored like that, so this is to be extra sure
168template <class Arg>
169struct throws_for_sure {
170 static const bool value
171 = throws_for_sure_phase2<
172 typename detail::remove_reference_and_cv<Arg>::type
173 >::value;
174};
175
176
177// -- return_or_throw templates -----------------------------
178
179// false case, catch and try return types are incompatible
180// Now the catch part must throw for sure, otherwise a compile time error
181// occurs.
182template<bool is_conversion>
183struct return_or_throw_phase2 {
184 template<class RET, class Arg, CALL_TEMPLATE_ARGS>
185 static RET call(Arg& arg, CALL_FORMAL_ARGS) {
186 BOOST_STATIC_ASSERT(throws_for_sure<Arg>::value);
187 detail::select(arg, CALL_ACTUAL_ARGS); // this line throws
188 throw 1; // this line is never performed, hence 1 is just a dummy
189 // The line is needed to make compiler happy and not require
190 // a matching return type
191 }
192};
193
194// the try and catch return types are compatible
195template<>
196struct return_or_throw_phase2<true> {
197 template<class RET, class Arg, CALL_TEMPLATE_ARGS>
198 static RET call(Arg& arg, CALL_FORMAL_ARGS) {
199 return detail::select(arg, CALL_ACTUAL_ARGS);
200 }
201};
202
203
204// the non-void case. Try part returns a value, so catch parts must
205// return a value of the same type or throw
206template<class RET, class ARG>
207struct return_or_throw {
208 // Arg should be equal to ARG except that ARG may be a reference
209 // to be sure, that there are no suprises for peculiarly defined return types
210 // ARG is passed explicitely
211 template<class Arg, CALL_TEMPLATE_ARGS>
212 static RET call(Arg& arg, CALL_FORMAL_ARGS)
213 {
214 // typedef typename Arg::return_type<ARG, open_args<A&, B&, C&> >::type RT;
215 typedef typename as_lambda_functor<ARG>::type lf_type;
216 typedef typename lf_type::inherited::template
217 sig<tuple<CALL_REFERENCE_TYPES> >::type RT;
218
219 return
220 return_or_throw_phase2<
221 ::boost::is_convertible<RT, RET>::value
222 >::template call<RET>(arg, CALL_ACTUAL_ARGS);
223 }
224};
225
226// if try part returns void, we do not return the catch parts either
227template<class ARG>
228struct return_or_throw<void, ARG> {
229 template<class Arg, CALL_TEMPLATE_ARGS>
230 static void call(Arg& arg, CALL_FORMAL_ARGS) { detail::select(arg, CALL_ACTUAL_ARGS); }
231};
232
233} // end detail
234
235// Throwing exceptions ---------------------------------------------
236
237namespace detail {
238
239template <class T> struct catch_block {};
240struct catch_all_block {};
241
242template <class T> struct exception_catch_tag {};
243
244// normal catch block is represented as
245// tagged_lambda_functor<exception_catch_tag<catch_type<T> > >, LambdaFunctor>
246
247// the default catch all block as:
248// tagged_lambda_functor<exception_catch_tag<catch_all_block> >, LambdaFunctor>
249
250
251} // end detail
252
253// the code is RETHROW, this ensures that a compile time error results,
254// if this lambda_functor is used outside a delayed catch_expression
255inline const
256lambda_functor<
257 lambda_functor_base<
258 action<0, throw_action<rethrow_action> >,
259 null_type
260 >
261>
262rethrow() {
263 return
264 lambda_functor_base<
265 action<0, throw_action<rethrow_action> >,
266 null_type
267 >
268 ( null_type() );
269}
270
271template <class Arg1>
272inline const
273lambda_functor<
274 lambda_functor_base<
275 action<1, throw_action<throw_new_action> >,
276 tuple<typename const_copy_argument<const Arg1>::type>
277 >
278>
279throw_exception(const Arg1& a1) {
280 return
281 lambda_functor_base<
282 action<1, throw_action<throw_new_action> >,
283 tuple<typename const_copy_argument<const Arg1>::type>
284 >
285 ( tuple<typename const_copy_argument<const Arg1>::type>(a1));
286}
287
288// create catch blocks
289template <class CatchType, class Arg>
290inline const
291tagged_lambda_functor<
292 detail::exception_catch_tag<detail::catch_block<CatchType> >,
293 lambda_functor<Arg>
294>
295catch_exception(const lambda_functor<Arg>& a) {
296 // the third placeholder cannot be used in catch_exception
297 // BOOST_STATIC_ASSERT((!has_placeholder<Arg, THIRD>::value));
298 return
299 tagged_lambda_functor<
300 detail::exception_catch_tag<detail::catch_block<CatchType> >,
301 lambda_functor<Arg>
302 > (a);
303}
304
305// catch and do nothing case.
306template <class CatchType>
307inline const
308tagged_lambda_functor<
309 detail::exception_catch_tag<detail::catch_block<CatchType> >,
310 lambda_functor<
311 lambda_functor_base<
312 do_nothing_action,
313 null_type
314 >
315 >
316>
317catch_exception() {
318 return
319 tagged_lambda_functor<
320 detail::exception_catch_tag<detail::catch_block<CatchType> >,
321 lambda_functor<
322 lambda_functor_base<
323 do_nothing_action,
324 null_type
325 >
326 >
327 > ();
328}
329
330// create catch(...) blocks
331template <class Arg>
332inline const
333tagged_lambda_functor<
334 detail::exception_catch_tag<detail::catch_all_block>,
335 lambda_functor<Arg>
336>
337catch_all(const lambda_functor<Arg>& a) {
338 // the third placeholder cannot be used in catch_exception
339 BOOST_STATIC_ASSERT((!has_placeholder<Arg, THIRD>::value));
340 return
341 tagged_lambda_functor<
342 detail::exception_catch_tag<detail::catch_all_block>,
343 lambda_functor<Arg>
344 > (a);
345}
346
347// catch(...) and do nothing case.
348inline const
349tagged_lambda_functor<
350 detail::exception_catch_tag<detail::catch_all_block>,
351 lambda_functor<
352 lambda_functor_base<
353 do_nothing_action,
354 null_type
355 >
356 >
357>
358catch_all() {
359 return
360 tagged_lambda_functor<
361 detail::exception_catch_tag<detail::catch_all_block>,
362 lambda_functor<
363 lambda_functor_base<
364 do_nothing_action,
365 null_type
366 >
367 >
368 > ();
369}
370
371// try_catch functions --------------------------------
372// The second -> N argument(s) are must be catch lambda_functors
373template <class TryArg, class Catch1, class LF1>
374inline const
375lambda_functor<
376 lambda_functor_base<
377 action<2, try_catch_action<catch_action<Catch1> > >,
378 tuple<lambda_functor<TryArg>, LF1>
379 >
380>
381try_catch(
382 const lambda_functor<TryArg>& a1,
383 const tagged_lambda_functor<detail::exception_catch_tag<Catch1>, LF1>& a2)
384{
385 return
386 lambda_functor_base<
387 action<2, try_catch_action<catch_action<Catch1> > >,
388 tuple<lambda_functor<TryArg>, LF1>
389 >
390 ( tuple< lambda_functor<TryArg>, LF1>(a1, a2));
391}
392
393template <class TryArg, class Catch1, class LF1,
394 class Catch2, class LF2>
395inline const
396 lambda_functor<
397 lambda_functor_base<
398 action<3, try_catch_action<catch_action<detail::catch_block<Catch1>, Catch2> > >,
399 tuple<lambda_functor<TryArg>, LF1, LF2>
400 >
401>
402try_catch(
403 const lambda_functor<TryArg>& a1,
404 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
405 const tagged_lambda_functor<detail::exception_catch_tag<Catch2>, LF2>& a3)
406{
407 return
408 lambda_functor_base<
409 action<3, try_catch_action<catch_action<detail::catch_block<Catch1>, Catch2> > >,
410 tuple<lambda_functor<TryArg>, LF1, LF2>
411 >
412 ( tuple<lambda_functor<TryArg>, LF1, LF2>(a1, a2, a3));
413}
414
415template <class TryArg, class Catch1, class LF1,
416 class Catch2, class LF2,
417 class Catch3, class LF3>
418inline const lambda_functor<
419 lambda_functor_base<
420 action<4, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, Catch3> > >,
421 tuple<lambda_functor<TryArg>, LF1, LF2, LF3>
422 >
423>
424try_catch(
425 const lambda_functor<TryArg>& a1,
426 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
427 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
428 const tagged_lambda_functor<detail::exception_catch_tag<Catch3>, LF3>& a4)
429{
430 return
431 lambda_functor_base<
432 action<4, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, Catch3> > >,
433 tuple<lambda_functor<TryArg>, LF1, LF2, LF3>
434 >
435 ( tuple<lambda_functor<TryArg>, LF1, LF2, LF3>(a1, a2, a3, a4));
436}
437
438template <class TryArg, class Catch1, class LF1,
439 class Catch2, class LF2,
440 class Catch3, class LF3,
441 class Catch4, class LF4>
442inline const
443lambda_functor<
444 lambda_functor_base<
445 action<
446 5,
447 try_catch_action<
448 catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, Catch4>
449 >
450 >,
451 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4>
452 >
453>
454try_catch(
455 const lambda_functor<TryArg>& a1,
456 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
457 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
458 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
459 const tagged_lambda_functor<detail::exception_catch_tag<Catch4>, LF4>& a5)
460{
461 return
462 lambda_functor_base<
463 action<
464 5,
465 try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, Catch4> >
466 >,
467 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4>
468 >
469 ( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4>(a1, a2, a3, a4, a5));
470}
471
472template <class TryArg, class Catch1, class LF1,
473 class Catch2, class LF2,
474 class Catch3, class LF3,
475 class Catch4, class LF4,
476 class Catch5, class LF5>
477inline const
478lambda_functor<
479 lambda_functor_base<
480 action<
481 6,
482 try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, Catch5> >
483 >,
484 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5>
485 >
486>
487try_catch(
488 const lambda_functor<TryArg>& a1,
489 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
490 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
491 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
492 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
493 const tagged_lambda_functor<detail::exception_catch_tag<Catch5>, LF5>& a6)
494{
495 return
496 lambda_functor_base<
497 action<
498 6,
499 try_catch_action<
500 catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, Catch5>
501 >
502 >,
503 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5>
504 >
505 ( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5>
506 (a1, a2, a3, a4, a5, a6)
507 );
508}
509
510template <class TryArg, class Catch1, class LF1,
511 class Catch2, class LF2,
512 class Catch3, class LF3,
513 class Catch4, class LF4,
514 class Catch5, class LF5,
515 class Catch6, class LF6>
516inline const
517lambda_functor<
518 lambda_functor_base<
519 action<
520 7,
521 try_catch_action<
522 catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, Catch6>
523 >
524 >,
525 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6>
526 >
527>
528try_catch(
529 const lambda_functor<TryArg>& a1,
530 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
531 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
532 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
533 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
534 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch5> >, LF5>& a6,
535 const tagged_lambda_functor<detail::exception_catch_tag<Catch6>, LF6>& a7)
536{
537 return
538 lambda_functor_base<
539 action<
540 7,
541 try_catch_action<
542 catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>,Catch6>
543 >
544 >,
545 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6>
546 >
547 ( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6>
548 (a1, a2, a3, a4, a5, a6, a7));
549}
550
551template <class TryArg, class Catch1, class LF1,
552 class Catch2, class LF2,
553 class Catch3, class LF3,
554 class Catch4, class LF4,
555 class Catch5, class LF5,
556 class Catch6, class LF6,
557 class Catch7, class LF7>
558inline const
559lambda_functor<
560 lambda_functor_base<
561 action<
562 8,
563 try_catch_action<
564 catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>, Catch7>
565 >
566 >,
567 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7>
568 >
569>
570try_catch(
571 const lambda_functor<TryArg>& a1,
572 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
573 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
574 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
575 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
576 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch5> >, LF5>& a6,
577 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch6> >, LF6>& a7,
578 const tagged_lambda_functor<detail::exception_catch_tag<Catch7>, LF7>& a8)
579{
580 return
581 lambda_functor_base<
582 action<
583 8,
584 try_catch_action<
585 catch_action<
586 detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>, Catch7
587 >
588 >
589 >,
590 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7>
591 >
592 ( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7>
593 (a1, a2, a3, a4, a5, a6, a7, a8));
594}
595
596template <class TryArg, class Catch1, class LF1,
597 class Catch2, class LF2,
598 class Catch3, class LF3,
599 class Catch4, class LF4,
600 class Catch5, class LF5,
601 class Catch6, class LF6,
602 class Catch7, class LF7,
603 class Catch8, class LF8>
604inline const
605lambda_functor<
606 lambda_functor_base<
607 action<
608 9,
609 try_catch_action<
610 catch_action<
611 detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>, detail::catch_block<Catch7>, Catch8
612 >
613 >
614 >,
615 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8>
616 >
617>
618try_catch(
619 const lambda_functor<TryArg>& a1,
620 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
621 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
622 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
623 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
624 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch5> >, LF5>& a6,
625 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch6> >, LF6>& a7,
626 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch7> >, LF7>& a8,
627 const tagged_lambda_functor<detail::exception_catch_tag<Catch8>, LF8>& a9)
628{
629 return
630 lambda_functor_base<
631 action<
632 9,
633 try_catch_action<
634 catch_action<
635 detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>, detail::catch_block<Catch7>, Catch8
636 >
637 >
638 >,
639 tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8>
640 >
641 ( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8>
642 (a1, a2, a3, a4, a5, a6, a7, a8, a9));
643}
644
645template <class TryArg, class Catch1, class LF1,
646 class Catch2, class LF2,
647 class Catch3, class LF3,
648 class Catch4, class LF4,
649 class Catch5, class LF5,
650 class Catch6, class LF6,
651 class Catch7, class LF7,
652 class Catch8, class LF8,
653 class Catch9, class LF9>
654inline const
655 lambda_functor<
656 lambda_functor_base<
657 action<
658 10,
659 try_catch_action<
660 catch_action<
661 detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>, detail::catch_block<Catch7>, detail::catch_block<Catch8>,
662 Catch9
663 >
664 >
665 >,
666 tuple<
667 lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9
668 >
669 >
670 >
671try_catch(
672 const lambda_functor<TryArg>& a1,
673 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
674 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
675 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
676 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
677 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch5> >, LF5>& a6,
678 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch6> >, LF6>& a7,
679 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch7> >, LF7>& a8,
680 const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch8> >, LF8>& a9,
681 const tagged_lambda_functor<detail::exception_catch_tag<Catch9>, LF9>& a10)
682{
683 return
684 lambda_functor_base<
685 action<
686 10,
687 try_catch_action<
688 catch_action<
689 detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>, detail::catch_block<Catch7>, detail::catch_block<Catch8>,
690 Catch9
691 >
692 >
693 >,
694 tuple<
695 lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9
696 >
697 >
698 ( tuple<
699 lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9
700 >(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
701}
702
703
704// ---------------------------------------------------------------------------
705// Specializations for lambda_functor_base of try_catch ----------------------
706
707// 1 catch type case
708
709template<class Args, class Catch1>
710class lambda_functor_base<
711 action<2, try_catch_action<catch_action<detail::catch_block<Catch1> > > >,
712 Args
713>
714{
715public:
716 Args args;
717public:
718 explicit lambda_functor_base(const Args& a) : args(a) {}
719
720// the return type of try_catch is the return type of the try lambda_functor
721// (the return types of try and catch parts must match unless try returns void
722// or the catch part throws for sure)
723
724 template <class SigArgs> struct sig {
725 typedef typename
726 as_lambda_functor<
727 typename boost::tuples::element<0, Args>::type
728 >::type lf_type;
729
730 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
731 };
732
733 template<class RET, CALL_TEMPLATE_ARGS>
734 RET call(CALL_FORMAL_ARGS) const {
735 try
736 {
737 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
738 }
739 catch (Catch1& e)
740 {
741 return
742 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
743 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
744 }
745 }
746};
747
748
749
750template<class Args>
751class lambda_functor_base<action<2, try_catch_action<catch_action<detail::catch_all_block> > >, Args> {
752public:
753 Args args;
754public:
755 explicit lambda_functor_base(const Args& a) : args(a) {}
756
757 template <class SigArgs> struct sig {
758 typedef typename
759 as_lambda_functor<
760 typename boost::tuples::element<0, Args>::type
761 >::type lf_type;
762
763 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
764 };
765
766 template<class RET, CALL_TEMPLATE_ARGS>
767 RET call(CALL_FORMAL_ARGS) const {
768 try
769 {
770 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
771 }
772 catch (...)
773 {
774 return
775 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
776 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
777 }
778 }
779};
780
781
782// 2 catch types case
783template<class Args, class Catch1, class Catch2>
784class lambda_functor_base<action<3, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2> > > >, Args> {
785public:
786 Args args;
787public:
788 explicit lambda_functor_base(const Args& a) : args(a) {}
789
790 template <class SigArgs> struct sig {
791 typedef typename
792 as_lambda_functor<
793 typename boost::tuples::element<0, Args>::type
794 >::type lf_type;
795
796 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
797 };
798
799 template<class RET, CALL_TEMPLATE_ARGS>
800 RET call(CALL_FORMAL_ARGS) const {
801 try
802 {
803 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
804 }
805 catch (Catch1& e)
806 {
807 return
808 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
809 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
810 }
811 catch (Catch2& e)
812 {
813 return
814 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
815 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
816 }
817 }
818};
819
820template<class Args, class Catch1>
821class lambda_functor_base<action<3, try_catch_action<catch_action<detail::catch_block<Catch1>,detail::catch_all_block> > >, Args> {
822public:
823 Args args;
824public:
825 explicit lambda_functor_base(const Args& a) : args(a) {}
826
827 template <class SigArgs> struct sig {
828 typedef typename
829 as_lambda_functor<
830 typename boost::tuples::element<0, Args>::type
831 >::type lf_type;
832
833 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
834 };
835
836 template<class RET, CALL_TEMPLATE_ARGS>
837 RET call(CALL_FORMAL_ARGS) const {
838 try
839 {
840 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
841 }
842 catch (Catch1& e)
843 {
844 return
845 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
846 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
847 }
848 catch (...)
849 {
850 return
851 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
852 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS);
853 }
854 }
855};
856
857// 3 catch types case
858template<class Args, class Catch1, class Catch2, class Catch3>
859class lambda_functor_base<action<4, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3> > > >, Args> {
860public:
861 Args args;
862public:
863 explicit lambda_functor_base(const Args& a) : args(a) {}
864
865 template <class SigArgs> struct sig {
866 typedef typename
867 as_lambda_functor<
868 typename boost::tuples::element<0, Args>::type
869 >::type lf_type;
870
871 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
872 };
873
874 template<class RET, CALL_TEMPLATE_ARGS>
875 RET call(CALL_FORMAL_ARGS) const {
876 try
877 {
878 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
879 }
880 catch (Catch1& e)
881 {
882 return
883 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
884 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
885
886 }
887 catch (Catch2& e)
888 {
889 return
890 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
891 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
892
893 }
894 catch (Catch3& e)
895 {
896 return
897 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
898 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
899 }
900 }
901};
902
903template<class Args, class Catch1, class Catch2>
904class lambda_functor_base<action<4, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>,detail::catch_all_block> > >, Args> {
905public:
906 Args args;
907public:
908 explicit lambda_functor_base(const Args& a) : args(a) {}
909
910 template <class SigArgs> struct sig {
911 typedef typename
912 as_lambda_functor<
913 typename boost::tuples::element<0, Args>::type
914 >::type lf_type;
915
916 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
917 };
918
919 template<class RET, CALL_TEMPLATE_ARGS>
920 RET call(CALL_FORMAL_ARGS) const {
921 try
922 {
923 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
924 }
925 catch (Catch1& e)
926 {
927 return
928 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
929 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
930 }
931 catch (Catch2& e)
932 {
933 return
934 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
935 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
936 }
937 catch (...)
938 {
939 return
940 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
941 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS);
942 }
943 }
944};
945
946// 4 catch types case
947template<class Args, class Catch1, class Catch2, class Catch3, class Catch4>
948class lambda_functor_base<action<5, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4> > > >, Args> {
949public:
950 Args args;
951public:
952 explicit lambda_functor_base(const Args& a) : args(a) {}
953
954 template <class SigArgs> struct sig {
955 typedef typename
956 as_lambda_functor<
957 typename boost::tuples::element<0, Args>::type
958 >::type lf_type;
959
960 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
961 };
962
963 template<class RET, CALL_TEMPLATE_ARGS>
964 RET call(CALL_FORMAL_ARGS) const {
965 try
966 {
967 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
968 }
969 catch (Catch1& e)
970 {
971 return
972 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
973 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
974 }
975 catch (Catch2& e)
976 {
977 return
978 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
979 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
980 }
981 catch (Catch3& e)
982 {
983 return
984 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
985 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
986 }
987 catch (Catch4& e)
988 {
989 return
990 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
991 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
992 }
993 }
994};
995
996template<class Args, class Catch1, class Catch2, class Catch3>
997class lambda_functor_base<action<5, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>,detail::catch_all_block> > >, Args> {
998public:
999 Args args;
1000public:
1001 explicit lambda_functor_base(const Args& a) : args(a) {}
1002
1003 template <class SigArgs> struct sig {
1004 typedef typename
1005 as_lambda_functor<
1006 typename boost::tuples::element<0, Args>::type
1007 >::type lf_type;
1008
1009 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1010 };
1011
1012 template<class RET, CALL_TEMPLATE_ARGS>
1013 RET call(CALL_FORMAL_ARGS) const {
1014 try
1015 {
1016 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1017 }
1018 catch (Catch1& e)
1019 {
1020 return
1021 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1022 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1023 }
1024 catch (Catch2& e)
1025 {
1026 return
1027 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1028 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1029 }
1030 catch (Catch3& e)
1031 {
1032 return
1033 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1034 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1035 }
1036 catch (...)
1037 {
1038 return
1039 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1040 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS);
1041 }
1042 }
1043};
1044
1045// 5 catch types case
1046template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5>
1047class lambda_functor_base<action<6, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5> > > >, Args> {
1048public:
1049 Args args;
1050public:
1051 explicit lambda_functor_base(const Args& a) : args(a) {}
1052
1053 template <class SigArgs> struct sig {
1054 typedef typename
1055 as_lambda_functor<
1056 typename boost::tuples::element<0, Args>::type
1057 >::type lf_type;
1058
1059 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1060 };
1061
1062 template<class RET, CALL_TEMPLATE_ARGS>
1063 RET call(CALL_FORMAL_ARGS) const {
1064 try
1065 {
1066 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1067 }
1068 catch (Catch1& e)
1069 {
1070 return
1071 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1072 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1073 }
1074 catch (Catch2& e)
1075 {
1076 return
1077 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1078 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1079 }
1080 catch (Catch3& e)
1081 {
1082 return
1083 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1084 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1085 }
1086 catch (Catch4& e)
1087 {
1088 return
1089 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1090 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1091 }
1092 catch (Catch5& e)
1093 {
1094 return
1095 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1096 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1097 }
1098 }
1099};
1100
1101template<class Args, class Catch1, class Catch2, class Catch3, class Catch4>
1102class lambda_functor_base<action<6, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>,detail::catch_all_block> > >, Args> {
1103public:
1104 Args args;
1105public:
1106 explicit lambda_functor_base(const Args& a) : args(a) {}
1107
1108 template <class SigArgs> struct sig {
1109 typedef typename
1110 as_lambda_functor<
1111 typename boost::tuples::element<0, Args>::type
1112 >::type lf_type;
1113
1114 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1115 };
1116
1117 template<class RET, CALL_TEMPLATE_ARGS>
1118 RET call(CALL_FORMAL_ARGS) const {
1119 try
1120 {
1121 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1122 }
1123 catch (Catch1& e)
1124 {
1125 return
1126 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1127 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1128 }
1129 catch (Catch2& e)
1130 {
1131 return
1132 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1133 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1134 }
1135 catch (Catch3& e)
1136 {
1137 return
1138 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1139 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1140 }
1141 catch (Catch4& e)
1142 {
1143 return
1144 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1145 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1146 }
1147 catch (...)
1148 {
1149 return
1150 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1151 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS);
1152 }
1153 }
1154};
1155
1156// 6 catch types case
1157template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5, class Catch6>
1158class lambda_functor_base<action<7, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6> > > >, Args> {
1159public:
1160 Args args;
1161public:
1162 explicit lambda_functor_base(const Args& a) : args(a) {}
1163
1164 template <class SigArgs> struct sig {
1165 typedef typename
1166 as_lambda_functor<
1167 typename boost::tuples::element<0, Args>::type
1168 >::type lf_type;
1169
1170 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1171 };
1172
1173 template<class RET, CALL_TEMPLATE_ARGS>
1174 RET call(CALL_FORMAL_ARGS) const {
1175 try
1176 {
1177 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1178 }
1179 catch (Catch1& e)
1180 {
1181 return
1182 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1183 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1184 }
1185 catch (Catch2& e)
1186 {
1187 return
1188 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1189 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1190 }
1191 catch (Catch3& e)
1192 {
1193 return
1194 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1195 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1196 }
1197 catch (Catch4& e)
1198 {
1199 return
1200 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1201 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1202 }
1203 catch (Catch5& e)
1204 {
1205 return
1206 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1207 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1208 }
1209 catch (Catch6& e)
1210 {
1211 return
1212 detail::return_or_throw<RET, typename ::boost::tuples::element<6, Args>::type>
1213 ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1214 }
1215 }
1216};
1217
1218template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5>
1219class lambda_functor_base<action<7, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>,detail::catch_all_block> > >, Args> {
1220public:
1221 Args args;
1222public:
1223 explicit lambda_functor_base(const Args& a) : args(a) {}
1224
1225 template <class SigArgs> struct sig {
1226 typedef typename
1227 as_lambda_functor<
1228 typename boost::tuples::element<0, Args>::type
1229 >::type lf_type;
1230
1231 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1232 };
1233
1234 template<class RET, CALL_TEMPLATE_ARGS>
1235 RET call(CALL_FORMAL_ARGS) const {
1236 try
1237 {
1238 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1239 }
1240 catch (Catch1& e)
1241 {
1242 return
1243 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1244 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1245 }
1246 catch (Catch2& e)
1247 {
1248 return
1249 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1250 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1251 }
1252 catch (Catch3& e)
1253 {
1254 return
1255 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1256 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1257 }
1258 catch (Catch4& e)
1259 {
1260 return
1261 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1262 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1263 }
1264 catch (Catch5& e)
1265 {
1266 return
1267 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1268 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1269 }
1270 catch (...)
1271 {
1272 return
1273 detail::return_or_throw<RET, typename ::boost::tuples::element<6, Args>::type>
1274 ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS);
1275 }
1276 }
1277};
1278
1279// 7 catch types case
1280template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5, class Catch6,
1281 class Catch7>
1282class lambda_functor_base<action<8, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>, detail::catch_block<Catch7> > > >, Args> {
1283public:
1284 Args args;
1285public:
1286 explicit lambda_functor_base(const Args& a) : args(a) {}
1287
1288 template <class SigArgs> struct sig {
1289 typedef typename
1290 as_lambda_functor<
1291 typename boost::tuples::element<0, Args>::type
1292 >::type lf_type;
1293
1294 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1295 };
1296
1297 template<class RET, CALL_TEMPLATE_ARGS>
1298 RET call(CALL_FORMAL_ARGS) const {
1299 try
1300 {
1301 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1302 }
1303 catch (Catch1& e)
1304 {
1305 return
1306 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1307 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1308 }
1309 catch (Catch2& e)
1310 {
1311 return
1312 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1313 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1314 }
1315 catch (Catch3& e)
1316 {
1317 return
1318 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1319 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1320 }
1321 catch (Catch4& e)
1322 {
1323 return
1324 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1325 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1326 }
1327 catch (Catch5& e)
1328 {
1329 return
1330 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1331 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1332 }
1333 catch (Catch6& e)
1334 {
1335 return
1336 detail::return_or_throw<RET, typename ::boost::tuples::element<6, Args>::type>
1337 ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1338 }
1339 catch (Catch7& e)
1340 {
1341 return
1342 detail::return_or_throw<RET, typename ::boost::tuples::element<7, Args>::type>
1343 ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1344 }
1345 }
1346};
1347
1348template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5, class Catch6>
1349class lambda_functor_base<action<8, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>,
1350 detail::catch_all_block> > >, Args> {
1351public:
1352 Args args;
1353public:
1354 explicit lambda_functor_base(const Args& a) : args(a) {}
1355
1356 template <class SigArgs> struct sig {
1357 typedef typename
1358 as_lambda_functor<
1359 typename boost::tuples::element<0, Args>::type
1360 >::type lf_type;
1361
1362 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1363 };
1364
1365 template<class RET, CALL_TEMPLATE_ARGS>
1366 RET call(CALL_FORMAL_ARGS) const {
1367 try
1368 {
1369 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1370 }
1371 catch (Catch1& e)
1372 {
1373 return
1374 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1375 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1376 }
1377 catch (Catch2& e)
1378 {
1379 return
1380 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1381 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1382 }
1383 catch (Catch3& e)
1384 {
1385 return
1386 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1387 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1388 }
1389 catch (Catch4& e)
1390 {
1391 return
1392 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1393 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1394 }
1395 catch (Catch5& e)
1396 {
1397 return
1398 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1399 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1400 }
1401 catch (Catch6& e)
1402 {
1403 return
1404 detail::return_or_throw<RET, typename ::boost::tuples::element<6, Args>::type>
1405 ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1406 }
1407 catch (...)
1408 {
1409 return
1410 detail::return_or_throw<RET, typename ::boost::tuples::element<7, Args>::type>
1411 ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS);
1412 }
1413 }
1414};
1415
1416// 8 catch types case
1417template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5, class Catch6,
1418 class Catch7, class Catch8>
1419class lambda_functor_base<action<9, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>,
1420 detail::catch_block<Catch7>, detail::catch_block<Catch8> > > >, Args> {
1421public:
1422 Args args;
1423public:
1424 explicit lambda_functor_base(const Args& a) : args(a) {}
1425
1426 template <class SigArgs> struct sig {
1427 typedef typename
1428 as_lambda_functor<
1429 typename boost::tuples::element<0, Args>::type
1430 >::type lf_type;
1431
1432 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1433 };
1434
1435 template<class RET, CALL_TEMPLATE_ARGS>
1436 RET call(CALL_FORMAL_ARGS) const {
1437 try
1438 {
1439 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1440 }
1441 catch (Catch1& e)
1442 {
1443 return
1444 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1445 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1446 }
1447 catch (Catch2& e)
1448 {
1449 return
1450 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1451 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1452 }
1453 catch (Catch3& e)
1454 {
1455 return
1456 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1457 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1458 }
1459 catch (Catch4& e)
1460 {
1461 return
1462 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1463 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1464 }
1465 catch (Catch5& e)
1466 {
1467 return
1468 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1469 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1470 }
1471 catch (Catch6& e)
1472 {
1473 return
1474 detail::return_or_throw<RET, typename ::boost::tuples::element<6, Args>::type>
1475 ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1476 }
1477 catch (Catch7& e)
1478 {
1479 return
1480 detail::return_or_throw<RET, typename ::boost::tuples::element<7, Args>::type>
1481 ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1482 }
1483 catch (Catch8& e)
1484 {
1485 return
1486 detail::return_or_throw<RET, typename ::boost::tuples::element<8, Args>::type>
1487 ::call(::boost::tuples::get<8>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1488 }
1489 }
1490};
1491
1492template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5, class Catch6,
1493 class Catch7>
1494class lambda_functor_base<action<9, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>,
1495 detail::catch_block<Catch7>,detail::catch_all_block> > >, Args> {
1496public:
1497 Args args;
1498public:
1499 explicit lambda_functor_base(const Args& a) : args(a) {}
1500
1501 template <class SigArgs> struct sig {
1502 typedef typename
1503 as_lambda_functor<
1504 typename boost::tuples::element<0, Args>::type
1505 >::type lf_type;
1506
1507 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1508 };
1509
1510 template<class RET, CALL_TEMPLATE_ARGS>
1511 RET call(CALL_FORMAL_ARGS) const {
1512 try
1513 {
1514 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1515 }
1516 catch (Catch1& e)
1517 {
1518 return
1519 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1520 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1521 }
1522 catch (Catch2& e)
1523 {
1524 return
1525 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1526 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1527 }
1528 catch (Catch3& e)
1529 {
1530 return
1531 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1532 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1533 }
1534 catch (Catch4& e)
1535 {
1536 return
1537 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1538 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1539 }
1540 catch (Catch5& e)
1541 {
1542 return
1543 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1544 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1545 }
1546 catch (Catch6& e)
1547 {
1548 return
1549 detail::return_or_throw<RET, typename ::boost::tuples::element<6, Args>::type>
1550 ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1551 }
1552 catch (Catch7& e)
1553 {
1554 return
1555 detail::return_or_throw<RET, typename ::boost::tuples::element<7, Args>::type>
1556 ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1557 }
1558 catch (...)
1559 {
1560 return
1561 detail::return_or_throw<RET, typename ::boost::tuples::element<8, Args>::type>
1562 ::call(::boost::tuples::get<8>(args), CALL_ACTUAL_ARGS);
1563 }
1564 }
1565};
1566
1567// 9 catch types case
1568template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5, class Catch6,
1569 class Catch7, class Catch8, class Catch9>
1570class lambda_functor_base<action<10, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>,
1571 detail::catch_block<Catch7>, detail::catch_block<Catch8>, detail::catch_block<Catch9> > > >, Args> {
1572public:
1573 Args args;
1574public:
1575 explicit lambda_functor_base(const Args& a) : args(a) {}
1576
1577 template <class SigArgs> struct sig {
1578 typedef typename
1579 as_lambda_functor<
1580 typename boost::tuples::element<0, Args>::type
1581 >::type lf_type;
1582
1583 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1584 };
1585
1586 template<class RET, CALL_TEMPLATE_ARGS>
1587 RET call(CALL_FORMAL_ARGS) const {
1588 try
1589 {
1590 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1591 }
1592 catch (Catch1& e)
1593 {
1594 return
1595 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1596 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1597 }
1598 catch (Catch2& e)
1599 {
1600 return
1601 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1602 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1603 }
1604 catch (Catch3& e)
1605 {
1606 return
1607 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1608 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1609 }
1610 catch (Catch4& e)
1611 {
1612 return
1613 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1614 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1615 }
1616 catch (Catch5& e)
1617 {
1618 return
1619 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1620 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1621 }
1622 catch (Catch6& e)
1623 {
1624 return
1625 detail::return_or_throw<RET, typename ::boost::tuples::element<6, Args>::type>
1626 ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1627 }
1628 catch (Catch7& e)
1629 {
1630 return
1631 detail::return_or_throw<RET, typename ::boost::tuples::element<7, Args>::type>
1632 ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1633 }
1634 catch (Catch8& e)
1635 {
1636 return
1637 detail::return_or_throw<RET, typename ::boost::tuples::element<8, Args>::type>
1638 ::call(::boost::tuples::get<8>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1639 }
1640 catch (Catch9& e)
1641 {
1642 return
1643 detail::return_or_throw<RET, typename ::boost::tuples::element<9, Args>::type>
1644 ::call(::boost::tuples::get<9>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1645 }
1646 }
1647};
1648
1649template<class Args, class Catch1, class Catch2, class Catch3, class Catch4, class Catch5, class Catch6,
1650 class Catch7, class Catch8>
1651class lambda_functor_base<action<10, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, detail::catch_block<Catch4>, detail::catch_block<Catch5>, detail::catch_block<Catch6>,
1652 detail::catch_block<Catch7>, detail::catch_block<Catch8>,detail::catch_all_block> > >, Args> {
1653public:
1654 Args args;
1655public:
1656 explicit lambda_functor_base(const Args& a) : args(a) {}
1657
1658 template <class SigArgs> struct sig {
1659 typedef typename
1660 as_lambda_functor<
1661 typename boost::tuples::element<0, Args>::type
1662 >::type lf_type;
1663
1664 typedef typename lf_type::inherited::template sig<SigArgs>::type type;
1665 };
1666
1667 template<class RET, CALL_TEMPLATE_ARGS>
1668 RET call(CALL_FORMAL_ARGS) const {
1669 try
1670 {
1671 return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
1672 }
1673 catch (Catch1& e)
1674 {
1675 return
1676 detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
1677 ::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1678 }
1679 catch (Catch2& e)
1680 {
1681 return
1682 detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
1683 ::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1684 }
1685 catch (Catch3& e)
1686 {
1687 return
1688 detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
1689 ::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1690 }
1691 catch (Catch4& e)
1692 {
1693 return
1694 detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
1695 ::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1696 }
1697 catch (Catch5& e)
1698 {
1699 return
1700 detail::return_or_throw<RET, typename ::boost::tuples::element<5, Args>::type>
1701 ::call(::boost::tuples::get<5>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1702 }
1703 catch (Catch6& e)
1704 {
1705 return
1706 detail::return_or_throw<RET, typename ::boost::tuples::element<6, Args>::type>
1707 ::call(::boost::tuples::get<6>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1708 }
1709 catch (Catch7& e)
1710 {
1711 return
1712 detail::return_or_throw<RET, typename ::boost::tuples::element<7, Args>::type>
1713 ::call(::boost::tuples::get<7>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1714 }
1715 catch (Catch8& e)
1716 {
1717 return
1718 detail::return_or_throw<RET, typename ::boost::tuples::element<8, Args>::type>
1719 ::call(::boost::tuples::get<8>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
1720 }
1721 catch (...)
1722 {
1723 return
1724 detail::return_or_throw<RET, typename ::boost::tuples::element<9, Args>::type>
1725 ::call(::boost::tuples::get<9>(args), CALL_ACTUAL_ARGS);
1726 }
1727 }
1728};
1729
1730
1731} // namespace lambda
1732} // namespace boost
1733
1734
1735#endif
1736
1737
1738
1739
1740
1741
1742