forked from Source-Python-Dev-Team/Source.Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.hpp
More file actions
1741 lines (1586 loc) · 58.4 KB
/
Copy pathexceptions.hpp
File metadata and controls
1741 lines (1586 loc) · 58.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// -- Boost Lambda Library -- exceptions.hpp ----------------
//
// Copyright (C) 2000 Gary Powell (gwpowell@hotmail.com)
// Copyright (C) 1999, 2000 Jaakko Jarvi (jaakko.jarvi@cs.utu.fi)
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see http://www.boost.org
// -----------------------------------------------------
#if !defined(BOOST_LAMBDA_EXCEPTIONS_HPP)
#define BOOST_LAMBDA_EXCEPTIONS_HPP
#include "boost/lambda/core.hpp"
#include "boost/lambda/detail/control_constructs_common.hpp"
namespace boost {
namespace lambda {
typedef lambda_functor<placeholder<EXCEPTION> > placeholderE_type;
namespace {
boost::lambda::placeholderE_type freeE;
boost::lambda::placeholderE_type& _e = freeE;
}
// -- exception related actions -------------------
// catch actions.
template <class Catch1, class Catch2 = null_type, class Catch3 = null_type,
class Catch4 = null_type, class Catch5 = null_type,
class Catch6 = null_type, class Catch7 = null_type,
class Catch8 = null_type, class Catch9 = null_type,
class Catch10 = null_type>
struct catch_action {};
struct catch_all_action {};
template<class CatchActions>
struct return_try_catch_action {};
template<class CatchActions>
struct try_catch_action {};
// rethrow actions
struct throw_new_action {};
struct rethrow_action {};
template<class ThrowType> struct throw_action;
template<>
struct throw_action<rethrow_action> {
template<class RET>
static RET apply() {
throw;
}
};
template<> struct throw_action<throw_new_action> {
template<class RET, class T>
static RET apply(T& t) {
throw t;
}
};
// return types for throw_actions --------------------------------------------
template<class T, class Any>
struct
return_type_N<throw_action<T>, Any> {
typedef void type;
};
// return types deductions -------------------------------------------------
// the return type of try_catch is the return type of the try lambda_functor
// (the return types of try and catch parts must match unless try returns void
// or the catch part throws for sure)
// NOTE, the exception placeholder deduction rule is defined
// in return_type_traits.hpp
// defined in control_constructs
class ifthenelse_action;
namespace detail {
// Templates for deducing, wether a lambda_functor throws inevitably of not -
// This mechanism is needed to make the compiler happy about
// return types of try and catch parts.
// a lambda_functor throws for sure if:
// - it is a throw expression
// - it is a comma expression, and one of its arguments throws for sure
// - it is an if_then_else expression and either the if statement or both
// the then and else throw.
// (there are other cases as well, but we do not cover them)
// e.g. _1 + (rethrow(), 3) does throw for sure but this is not checked
// This implies, that in such a case, the return types of try and catch parts
// must match if the try part returns other than void.
// (Such checks could be done though)
template <class Arg>
struct throws_for_sure_phase2 {
static const bool value = false;
};
template <int N, class ThrowType, class Args>
struct throws_for_sure_phase2<
lambda_functor<
lambda_functor_base<action<N, throw_action<ThrowType> >, Args>
>
>
{
static const bool value = true;
};
// Both then and else or the if throw of an if_then_else.
template <class Args>
struct throws_for_sure_phase2<
lambda_functor<
lambda_functor_base<
ifthenelse_action, Args
>
>
>
{
static const bool value =
throws_for_sure_phase2<
typename boost::tuples::element<0, Args>::type>::value
||
(
throws_for_sure_phase2<
typename boost::tuples::element<1, Args>::type
>::value
&&
throws_for_sure_phase2<
typename boost::tuples::element<2, Args>::type
>::value
);
};
template <class Args>
struct throws_for_sure_phase2<
lambda_functor<
lambda_functor_base< other_action<comma_action>, Args>
>
>
{
static const bool value =
throws_for_sure_phase2<
typename boost::tuples::element<0, Args>::type
>::value
||
throws_for_sure_phase2<
typename boost::tuples::element<1, Args>::type
>::value;
};
// get rid of any qualifiers and references
// lambda_functors should be stored like that, so this is to be extra sure
template <class Arg>
struct throws_for_sure {
static const bool value
= throws_for_sure_phase2<
typename detail::remove_reference_and_cv<Arg>::type
>::value;
};
// -- return_or_throw templates -----------------------------
// false case, catch and try return types are incompatible
// Now the catch part must throw for sure, otherwise a compile time error
// occurs.
template<bool is_conversion>
struct return_or_throw_phase2 {
template<class RET, class Arg, CALL_TEMPLATE_ARGS>
static RET call(Arg& arg, CALL_FORMAL_ARGS) {
BOOST_STATIC_ASSERT(throws_for_sure<Arg>::value);
detail::select(arg, CALL_ACTUAL_ARGS); // this line throws
throw 1; // this line is never performed, hence 1 is just a dummy
// The line is needed to make compiler happy and not require
// a matching return type
}
};
// the try and catch return types are compatible
template<>
struct return_or_throw_phase2<true> {
template<class RET, class Arg, CALL_TEMPLATE_ARGS>
static RET call(Arg& arg, CALL_FORMAL_ARGS) {
return detail::select(arg, CALL_ACTUAL_ARGS);
}
};
// the non-void case. Try part returns a value, so catch parts must
// return a value of the same type or throw
template<class RET, class ARG>
struct return_or_throw {
// Arg should be equal to ARG except that ARG may be a reference
// to be sure, that there are no suprises for peculiarly defined return types
// ARG is passed explicitely
template<class Arg, CALL_TEMPLATE_ARGS>
static RET call(Arg& arg, CALL_FORMAL_ARGS)
{
// typedef typename Arg::return_type<ARG, open_args<A&, B&, C&> >::type RT;
typedef typename as_lambda_functor<ARG>::type lf_type;
typedef typename lf_type::inherited::template
sig<tuple<CALL_REFERENCE_TYPES> >::type RT;
return
return_or_throw_phase2<
::boost::is_convertible<RT, RET>::value
>::template call<RET>(arg, CALL_ACTUAL_ARGS);
}
};
// if try part returns void, we do not return the catch parts either
template<class ARG>
struct return_or_throw<void, ARG> {
template<class Arg, CALL_TEMPLATE_ARGS>
static void call(Arg& arg, CALL_FORMAL_ARGS) { detail::select(arg, CALL_ACTUAL_ARGS); }
};
} // end detail
// Throwing exceptions ---------------------------------------------
namespace detail {
template <class T> struct catch_block {};
struct catch_all_block {};
template <class T> struct exception_catch_tag {};
// normal catch block is represented as
// tagged_lambda_functor<exception_catch_tag<catch_type<T> > >, LambdaFunctor>
// the default catch all block as:
// tagged_lambda_functor<exception_catch_tag<catch_all_block> >, LambdaFunctor>
} // end detail
// the code is RETHROW, this ensures that a compile time error results,
// if this lambda_functor is used outside a delayed catch_expression
inline const
lambda_functor<
lambda_functor_base<
action<0, throw_action<rethrow_action> >,
null_type
>
>
rethrow() {
return
lambda_functor_base<
action<0, throw_action<rethrow_action> >,
null_type
>
( null_type() );
}
template <class Arg1>
inline const
lambda_functor<
lambda_functor_base<
action<1, throw_action<throw_new_action> >,
tuple<typename const_copy_argument<const Arg1>::type>
>
>
throw_exception(const Arg1& a1) {
return
lambda_functor_base<
action<1, throw_action<throw_new_action> >,
tuple<typename const_copy_argument<const Arg1>::type>
>
( tuple<typename const_copy_argument<const Arg1>::type>(a1));
}
// create catch blocks
template <class CatchType, class Arg>
inline const
tagged_lambda_functor<
detail::exception_catch_tag<detail::catch_block<CatchType> >,
lambda_functor<Arg>
>
catch_exception(const lambda_functor<Arg>& a) {
// the third placeholder cannot be used in catch_exception
// BOOST_STATIC_ASSERT((!has_placeholder<Arg, THIRD>::value));
return
tagged_lambda_functor<
detail::exception_catch_tag<detail::catch_block<CatchType> >,
lambda_functor<Arg>
> (a);
}
// catch and do nothing case.
template <class CatchType>
inline const
tagged_lambda_functor<
detail::exception_catch_tag<detail::catch_block<CatchType> >,
lambda_functor<
lambda_functor_base<
do_nothing_action,
null_type
>
>
>
catch_exception() {
return
tagged_lambda_functor<
detail::exception_catch_tag<detail::catch_block<CatchType> >,
lambda_functor<
lambda_functor_base<
do_nothing_action,
null_type
>
>
> ();
}
// create catch(...) blocks
template <class Arg>
inline const
tagged_lambda_functor<
detail::exception_catch_tag<detail::catch_all_block>,
lambda_functor<Arg>
>
catch_all(const lambda_functor<Arg>& a) {
// the third placeholder cannot be used in catch_exception
BOOST_STATIC_ASSERT((!has_placeholder<Arg, THIRD>::value));
return
tagged_lambda_functor<
detail::exception_catch_tag<detail::catch_all_block>,
lambda_functor<Arg>
> (a);
}
// catch(...) and do nothing case.
inline const
tagged_lambda_functor<
detail::exception_catch_tag<detail::catch_all_block>,
lambda_functor<
lambda_functor_base<
do_nothing_action,
null_type
>
>
>
catch_all() {
return
tagged_lambda_functor<
detail::exception_catch_tag<detail::catch_all_block>,
lambda_functor<
lambda_functor_base<
do_nothing_action,
null_type
>
>
> ();
}
// try_catch functions --------------------------------
// The second -> N argument(s) are must be catch lambda_functors
template <class TryArg, class Catch1, class LF1>
inline const
lambda_functor<
lambda_functor_base<
action<2, try_catch_action<catch_action<Catch1> > >,
tuple<lambda_functor<TryArg>, LF1>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<Catch1>, LF1>& a2)
{
return
lambda_functor_base<
action<2, try_catch_action<catch_action<Catch1> > >,
tuple<lambda_functor<TryArg>, LF1>
>
( tuple< lambda_functor<TryArg>, LF1>(a1, a2));
}
template <class TryArg, class Catch1, class LF1,
class Catch2, class LF2>
inline const
lambda_functor<
lambda_functor_base<
action<3, try_catch_action<catch_action<detail::catch_block<Catch1>, Catch2> > >,
tuple<lambda_functor<TryArg>, LF1, LF2>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
const tagged_lambda_functor<detail::exception_catch_tag<Catch2>, LF2>& a3)
{
return
lambda_functor_base<
action<3, try_catch_action<catch_action<detail::catch_block<Catch1>, Catch2> > >,
tuple<lambda_functor<TryArg>, LF1, LF2>
>
( tuple<lambda_functor<TryArg>, LF1, LF2>(a1, a2, a3));
}
template <class TryArg, class Catch1, class LF1,
class Catch2, class LF2,
class Catch3, class LF3>
inline const lambda_functor<
lambda_functor_base<
action<4, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, Catch3> > >,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
const tagged_lambda_functor<detail::exception_catch_tag<Catch3>, LF3>& a4)
{
return
lambda_functor_base<
action<4, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, Catch3> > >,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3>
>
( tuple<lambda_functor<TryArg>, LF1, LF2, LF3>(a1, a2, a3, a4));
}
template <class TryArg, class Catch1, class LF1,
class Catch2, class LF2,
class Catch3, class LF3,
class Catch4, class LF4>
inline const
lambda_functor<
lambda_functor_base<
action<
5,
try_catch_action<
catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, Catch4>
>
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
const tagged_lambda_functor<detail::exception_catch_tag<Catch4>, LF4>& a5)
{
return
lambda_functor_base<
action<
5,
try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3>, Catch4> >
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4>
>
( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4>(a1, a2, a3, a4, a5));
}
template <class TryArg, class Catch1, class LF1,
class Catch2, class LF2,
class Catch3, class LF3,
class Catch4, class LF4,
class Catch5, class LF5>
inline const
lambda_functor<
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>, Catch5> >
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
const tagged_lambda_functor<detail::exception_catch_tag<Catch5>, LF5>& a6)
{
return
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>, Catch5>
>
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5>
>
( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5>
(a1, a2, a3, a4, a5, a6)
);
}
template <class TryArg, class Catch1, class LF1,
class Catch2, class LF2,
class Catch3, class LF3,
class Catch4, class LF4,
class Catch5, class LF5,
class Catch6, class LF6>
inline const
lambda_functor<
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>, Catch6>
>
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch5> >, LF5>& a6,
const tagged_lambda_functor<detail::exception_catch_tag<Catch6>, LF6>& a7)
{
return
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>,Catch6>
>
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6>
>
( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6>
(a1, a2, a3, a4, a5, a6, a7));
}
template <class TryArg, class Catch1, class LF1,
class Catch2, class LF2,
class Catch3, class LF3,
class Catch4, class LF4,
class Catch5, class LF5,
class Catch6, class LF6,
class Catch7, class LF7>
inline const
lambda_functor<
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>, Catch7>
>
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch5> >, LF5>& a6,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch6> >, LF6>& a7,
const tagged_lambda_functor<detail::exception_catch_tag<Catch7>, LF7>& a8)
{
return
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>, Catch7
>
>
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7>
>
( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7>
(a1, a2, a3, a4, a5, a6, a7, a8));
}
template <class TryArg, class Catch1, class LF1,
class Catch2, class LF2,
class Catch3, class LF3,
class Catch4, class LF4,
class Catch5, class LF5,
class Catch6, class LF6,
class Catch7, class LF7,
class Catch8, class LF8>
inline const
lambda_functor<
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>, detail::catch_block<Catch7>, Catch8
>
>
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch5> >, LF5>& a6,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch6> >, LF6>& a7,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch7> >, LF7>& a8,
const tagged_lambda_functor<detail::exception_catch_tag<Catch8>, LF8>& a9)
{
return
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>, detail::catch_block<Catch7>, Catch8
>
>
>,
tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8>
>
( tuple<lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8>
(a1, a2, a3, a4, a5, a6, a7, a8, a9));
}
template <class TryArg, class Catch1, class LF1,
class Catch2, class LF2,
class Catch3, class LF3,
class Catch4, class LF4,
class Catch5, class LF5,
class Catch6, class LF6,
class Catch7, class LF7,
class Catch8, class LF8,
class Catch9, class LF9>
inline const
lambda_functor<
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>, detail::catch_block<Catch7>, detail::catch_block<Catch8>,
Catch9
>
>
>,
tuple<
lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9
>
>
>
try_catch(
const lambda_functor<TryArg>& a1,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch1> >, LF1>& a2,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch2> >, LF2>& a3,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch3> >, LF3>& a4,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch4> >, LF4>& a5,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch5> >, LF5>& a6,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch6> >, LF6>& a7,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch7> >, LF7>& a8,
const tagged_lambda_functor<detail::exception_catch_tag<detail::catch_block<Catch8> >, LF8>& a9,
const tagged_lambda_functor<detail::exception_catch_tag<Catch9>, LF9>& a10)
{
return
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>, detail::catch_block<Catch7>, detail::catch_block<Catch8>,
Catch9
>
>
>,
tuple<
lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9
>
>
( tuple<
lambda_functor<TryArg>, LF1, LF2, LF3, LF4, LF5, LF6, LF7, LF8, LF9
>(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10));
}
// ---------------------------------------------------------------------------
// Specializations for lambda_functor_base of try_catch ----------------------
// 1 catch type case
template<class Args, class Catch1>
class lambda_functor_base<
action<2, try_catch_action<catch_action<detail::catch_block<Catch1> > > >,
Args
>
{
public:
Args args;
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
// the return type of try_catch is the return type of the try lambda_functor
// (the return types of try and catch parts must match unless try returns void
// or the catch part throws for sure)
template <class SigArgs> struct sig {
typedef typename
as_lambda_functor<
typename boost::tuples::element<0, Args>::type
>::type lf_type;
typedef typename lf_type::inherited::template sig<SigArgs>::type type;
};
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
try
{
return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
}
catch (Catch1& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
}
};
template<class Args>
class lambda_functor_base<action<2, try_catch_action<catch_action<detail::catch_all_block> > >, Args> {
public:
Args args;
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template <class SigArgs> struct sig {
typedef typename
as_lambda_functor<
typename boost::tuples::element<0, Args>::type
>::type lf_type;
typedef typename lf_type::inherited::template sig<SigArgs>::type type;
};
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
try
{
return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
}
catch (...)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS);
}
}
};
// 2 catch types case
template<class Args, class Catch1, class Catch2>
class lambda_functor_base<action<3, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2> > > >, Args> {
public:
Args args;
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template <class SigArgs> struct sig {
typedef typename
as_lambda_functor<
typename boost::tuples::element<0, Args>::type
>::type lf_type;
typedef typename lf_type::inherited::template sig<SigArgs>::type type;
};
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
try
{
return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
}
catch (Catch1& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (Catch2& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
}
};
template<class Args, class Catch1>
class lambda_functor_base<action<3, try_catch_action<catch_action<detail::catch_block<Catch1>,detail::catch_all_block> > >, Args> {
public:
Args args;
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template <class SigArgs> struct sig {
typedef typename
as_lambda_functor<
typename boost::tuples::element<0, Args>::type
>::type lf_type;
typedef typename lf_type::inherited::template sig<SigArgs>::type type;
};
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
try
{
return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
}
catch (Catch1& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (...)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS);
}
}
};
// 3 catch types case
template<class Args, class Catch1, class Catch2, class Catch3>
class lambda_functor_base<action<4, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>, detail::catch_block<Catch3> > > >, Args> {
public:
Args args;
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template <class SigArgs> struct sig {
typedef typename
as_lambda_functor<
typename boost::tuples::element<0, Args>::type
>::type lf_type;
typedef typename lf_type::inherited::template sig<SigArgs>::type type;
};
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
try
{
return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
}
catch (Catch1& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (Catch2& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (Catch3& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
}
};
template<class Args, class Catch1, class Catch2>
class lambda_functor_base<action<4, try_catch_action<catch_action<detail::catch_block<Catch1>, detail::catch_block<Catch2>,detail::catch_all_block> > >, Args> {
public:
Args args;
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template <class SigArgs> struct sig {
typedef typename
as_lambda_functor<
typename boost::tuples::element<0, Args>::type
>::type lf_type;
typedef typename lf_type::inherited::template sig<SigArgs>::type type;
};
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
try
{
return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
}
catch (Catch1& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (Catch2& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (...)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS);
}
}
};
// 4 catch types case
template<class Args, class Catch1, class Catch2, class Catch3, class Catch4>
class 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> {
public:
Args args;
public:
explicit lambda_functor_base(const Args& a) : args(a) {}
template <class SigArgs> struct sig {
typedef typename
as_lambda_functor<
typename boost::tuples::element<0, Args>::type
>::type lf_type;
typedef typename lf_type::inherited::template sig<SigArgs>::type type;
};
template<class RET, CALL_TEMPLATE_ARGS>
RET call(CALL_FORMAL_ARGS) const {
try
{
return detail::select(::boost::tuples::get<0>(args), CALL_ACTUAL_ARGS);
}
catch (Catch1& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<1, Args>::type>
::call(::boost::tuples::get<1>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (Catch2& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<2, Args>::type>
::call(::boost::tuples::get<2>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (Catch3& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<3, Args>::type>
::call(::boost::tuples::get<3>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
catch (Catch4& e)
{
return
detail::return_or_throw<RET, typename ::boost::tuples::element<4, Args>::type>
::call(::boost::tuples::get<4>(args), CALL_ACTUAL_ARGS_NO_ENV, e);
}
}
};
template<class Args, class Catch1, class Catch2, class Catch3>
class 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> {
public:
Args args;
public: