110 INFO(
"Test 00_usage: START: Implementation = functional "+std::to_string(
FUNCTIONAL_IMPL )+
".hpp");
111 fprintf(stderr,
"Implementation: functional %d, is_rtti_available %d, limited_lambda_id %d\n",
122 typedef jau::function<bool(std::vector<uint8_t>& ,
bool )> SomeFunc;
124 SomeFunc fa1 =
nullptr;
131 volatile int i = 100;
133 function<int(
int)> fa0 = [&](
int a) ->
int {
136 fprintf(stderr,
"lambda.0: %s, signature %s\n", fa0.toString().c_str(), fa0.signature().internal_name());
139 function<int(
int)> fa1 = lambda_01();
140 fprintf(stderr,
"lambda.1: %s, signature %s\n", fa1.toString().c_str(), fa1.signature().internal_name());
143 auto fa2_stub = [&](
int a) ->
int {
146 function<int(
int)> fa2_a = fa2_stub;
147 fprintf(stderr,
"lambda.2_a: %s, signature %s\n", fa2_a.toString().c_str(), fa2_a.signature().internal_name());
150 function<int(
int)> fa2_b = fa2_stub;
151 fprintf(stderr,
"lambda.2_b: %s, signature %s\n", fa2_b.toString().c_str(), fa2_b.signature().internal_name());
154 test_function0_result_____(
"lambda.0_1_", 1, 101, fa0, fa1);
155 test_function0________type(
"lambda.0_1_",
false, fa0, fa1);
156 test_function0_result_____(
"lambda.0_2a", 1, 101, fa0, fa2_a);
157 test_function0_result_____(
"lambda.0_2b", 1, 101, fa0, fa2_b);
160 fprintf(stderr,
"INFO: limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
162 fprintf(stderr,
"INFO: limited_lambda_id FIXED: %s:%d\n", __FILE__, __LINE__);
163 test_function0________type(
"lambda.0_2a",
false, fa0, fa2_a);
166 fprintf(stderr,
"INFO: limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
168 fprintf(stderr,
"INFO: limited_lambda_id FIXED: %s:%d\n", __FILE__, __LINE__);
169 test_function0________type(
"lambda.0_2b",
false, fa0, fa2_b);
172 fprintf(stderr,
"INFO: !limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
173 test_function0________type(
"lambda.0_2a",
false, fa0, fa2_a);
174 test_function0________type(
"lambda.0_2b",
false, fa0, fa2_b);
176 test_function0_result_____(
"lambda.2a2b", 1, 101, fa2_a, fa2_b);
177 test_function0________type(
"lambda.2a2b",
true, fa2_a, fa2_b);
180#if ( FUNCTIONAL_IMPL == 1 )
183 function<int(
int)> f_1 = [](
int a) ->
int {
186 fprintf(stderr,
"lambda.3_1 (plain) %s, signature %s\n", f_1.toString().c_str(), f_1.signature().internal_name());
188 test_function0_result_type(
"lambda.3131",
true, 1, 101, f_1, f_1);
190 function<int(
int)> f_2 =
function<int(
int)>::bind_lambda( [](
int x) ->
int {
193 fprintf(stderr,
"lambda.3_2 (plain) %s, signature %s\n", f_2.toString().c_str(), f_2.signature().internal_name());
195 test_function0_result_type(
"lambda.3232",
true, 1, 101, f_2, f_2);
199 function<int(
int)> f_1 =
function<int(
int)>::bind_ylambda( [](
auto& self,
int x) ->
int {
203 return x * self(x-1);
206 fprintf(stderr,
"ylambda.1_1 (plain) %s, signature %s\n", f_1.toString().c_str(), f_1.signature().internal_name());
208 test_function0_result_type(
"ylambda.1111",
true, 4, 24, f_1, f_1);
212 function<int(
int)> f_1 =
function<int(
int)>::bind_ylambda( [](
function<
int(
int)>::delegate_type& self,
int x) ->
int {
216 return x * self(x-1);
219 fprintf(stderr,
"ylambda.1_2 (plain) %s, signature %s\n", f_1.toString().c_str(), f_1.signature().internal_name());
221 test_function0_result_type(
"ylambda.1111",
true, 4, 24, f_1, f_1);
226 typedef int(*cfunc)(int);
227 volatile int i = 100;
229 auto f = ( [](
int a) ->
int {
234 fprintf(stderr,
"plain lambda.0 %s\n", fl_.toString().c_str());
237 test_function0_result_type(
"FuncPtr1a_free_10",
true, 1, 101, fl_, fl_);
243 typedef void(*cfunc)();
244 function<void()> fl_0 = (cfunc) ( []() ->
void {
247 fprintf(stderr,
"freeA.0 %s\n", fl_0.toString().c_str());
251 fprintf(stderr,
"freeA.1 %s\n", f2a_0.toString().c_str());
255 fprintf(stderr,
"freeA.2 %s\n", f2a_1.toString().c_str());
259 fprintf(stderr,
"freeA.3 %s\n", f20a_1.toString().c_str());
263 fprintf(stderr,
"freeA.4 %s\n", f20a_2.toString().c_str());
266 test_function2________type(
"FuncPtr1a_free_10",
true, fl_0, fl_0);
267 test_function2________type(
"FuncPtr1a_free_10",
true, f2a_0, f2a_1);
268 test_function2________type(
"FuncPtr1a_free_10",
true, f2a_1, f2a_1);
269 test_function2________type(
"FuncPtr3a_free_11",
true, f20a_1, f20a_1);
270 test_function2________type(
"FuncPtr3a_free_12",
true, f20a_1, f20a_2);
271 test_function2________type(
"FuncPtr1a_free_10",
false, f2a_1, f20a_1);
276 typedef int(*cfunc)(int);
277 function<int(
int)> fl_0 = (cfunc) ( [](
int i) ->
int {
281 fprintf(stderr,
"freeB.0 %s\n", fl_0.toString().c_str());
285 fprintf(stderr,
"freeB.1 %s\n", f1a_0.toString().c_str());
291 test_function0_result_type(
"FuncPtr1a_free_10",
true, 1, 101, fl_0, fl_0);
292 test_function0_result_type(
"FuncPtr1a_free_10",
true, 1, 101, f1a_0, f1a_1);
293 test_function0_result_type(
"FuncPtr1a_free_10",
true, 1, 101, f1a_1, f1a_1);
294 test_function0_result_type(
"FuncPtr3a_free_11",
true, 1, 101, f3a_1, f3a_1);
295 test_function0_result_type(
"FuncPtr3a_free_12",
true, 1, 101, f3a_1, f3a_2);
296 test_function0_result_type(
"FuncPtr1a_free_10",
false, 1, 101, f1a_1, f3a_1);
300 typedef void(*cfunc)(
int&, int);
301 function<void(
int&,
int)> fl_0 = (cfunc) ( [](
int& res,
int i) ->
void {
306 function<void(
int&,
int)> f3a_0 = &TestFunction01::Func13a_static;
309 test_function1_result_type(
"FuncPtr1a_free_10",
true, 1, 101, fl_0, fl_0);
310 test_function1_result_type(
"FuncPtr1a_free_10",
true, 1, 101, f1a_1, f1a_0);
311 test_function1_result_type(
"FuncPtr3a_free_11",
true, 1, 101, f3a_1, f3a_0);
312 test_function1_result_type(
"FuncPtr3a_free_11",
true, 1, 101, f3a_1, f3a_1);
313 test_function1_result_type(
"FuncPtr3a_free_12",
true, 1, 101, f3a_1, f3a_2);
314 test_function1_result_type(
"FuncPtr1a_free_10",
false, 1, 101, f1a_1, f3a_1);
318 function<int(
int)> f2a_0(
this, &TestFunction01::func02a_member);
319 fprintf(stderr,
"memberA.0 %s\n", f2a_0.toString().c_str());
323 fprintf(stderr,
"memberA.1 %s\n", f2a_1.toString().c_str());
328 test_function0_result_type(
"FuncPtr2a_member_12",
true, 1, 101, f2a_1, f2a_0);
329 test_function0_result_type(
"FuncPtr2a_member_12",
true, 1, 101, f2a_1, f2a_2);
330 test_function0_result_type(
"FuncPtr2a_member_12",
false, 1, 101, f2a_1, f2b_1);
334 function<void(
int&,
int)> f2a_0(
this, &TestFunction01::func12a_member);
338 test_function1_result_type(
"FuncPtr2a_member_12",
true, 1, 101, f2a_1, f2a_0);
339 test_function1_result_type(
"FuncPtr2a_member_12",
true, 1, 101, f2a_1, f2a_2);
340 test_function1_result_type(
"FuncPtr2a_member_12",
false, 1, 101, f2a_1, f2b_1);
346 typedef int(*cfunc)(
int&, int);
348 int(*func5a_capture)(
int&, int) = [](
int& capture,
int i)->int {
349 int res = i+10000+capture;
353 int(*func5b_capture)(
int&, int) = [](
int& capture,
int i)->int {
354 int res = i+100000+capture;
358 function<int(
int)> f5_o100_0(offset100,
359 (cfunc) ( [](
int& capture,
int i)->
int {
360 int res = i+10000+capture;
363 fprintf(stderr,
"capvalA.0 %s\n", f5_o100_0.toString().c_str());
367 (cfunc) ( [](
int& capture,
int i)->
int {
368 int res = i+10000+capture;
372 (cfunc) ( [](
int& capture,
int i)->
int {
373 int res = i+10000+capture;
376 test_function0________type(
"FuncPtr5a_o100_capture_00",
true, f5_o100_0, f5_o100_0);
377 test_function0________type(
"FuncPtr5a_o100_capture_00",
true, f5_o100_1, f5_o100_1);
378 test_function0________type(
"FuncPtr5a_o100_capture_00",
false, f5_o100_1, f5_o100_2);
380 function<int(
int)> f5a_o100_0(offset100, func5a_capture);
381 fprintf(stderr,
"capvalA.1 %s\n", f5a_o100_0.toString().c_str());
387 test_function0________type(
"FuncPtr5a_o100_capture_12",
true, f5a_o100_1, f5a_o100_0);
388 test_function0________type(
"FuncPtr5a_o100_capture_12",
true, f5a_o100_1, f5a_o100_2);
389 test_function0________type(
"FuncPtr5a_o100_capture_12",
false, f5a_o100_1, f5b_o100_1);
390 test_function0_result_type(
"FuncPtr5a_o100_capture_11",
true, 1, 10101, f5a_o100_1, f5a_o100_1);
391 test_function0_result_type(
"FuncPtr5a_o100_capture_12",
true, 1, 10101, f5a_o100_1, f5a_o100_2);
392 test_function0_result_type(
"FuncPtr5a_o100_capture_12",
false, 1, 10101, f5a_o100_1, f5b_o100_1);
396 IntOffset offset100(100);
398 typedef int(*cfunc)(IntOffset*, int);
400 int(*func7a_capture)(IntOffset*, int) = [](IntOffset* capture,
int i)->int {
401 int res = i+10000+capture->value;
404 int(*func7b_capture)(IntOffset*, int) = [](IntOffset* capture,
int i)->int {
405 int res = i+100000+capture->value;
410 (cfunc) ( [](IntOffset* capture,
int i)->
int {
411 int res = i+10000+capture->value;
414 fprintf(stderr,
"caprefA.0 %s\n", f7_o100_1.toString().c_str());
418 (cfunc) ( [](IntOffset* capture,
int i)->
int {
419 int res = i+10000+capture->value;
422 test_function0________type(
"FuncPtr7a_o100_capture_00",
true, f7_o100_1, f7_o100_1);
423 test_function0________type(
"FuncPtr7a_o100_capture_00",
false, f7_o100_1, f7_o100_2);
426 fprintf(stderr,
"caprefA.1 %s\n", f7a_o100_1.toString().c_str());
430 test_function0________type(
"FuncPtr7a_o100_capture_12",
true, f7a_o100_1, f7a_o100_2);
431 test_function0________type(
"FuncPtr7a_o100_capture_12",
false, f7a_o100_1, f7b_o100_1);
432 test_function0_result_type(
"FuncPtr7a_o100_capture_11",
true, 1, 10101, f7a_o100_1, f7a_o100_1);
433 test_function0_result_type(
"FuncPtr7a_o100_capture_12",
true, 1, 10101, f7a_o100_1, f7a_o100_2);
434 test_function0_result_type(
"FuncPtr7a_o100_capture_12",
false, 1, 10101, f7a_o100_1, f7b_o100_1);
438 std::function<int(
int i)> func4a_stdlambda = [](
int i)->
int {
442 std::function<int(
int i)> func4b_stdlambda = [](
int i)->
int {
447 fprintf(stderr,
"stdfunc.0 %s\n", f4a_1.toString().c_str());
451 test_function0_result_type(
"FuncPtr4a_stdlambda_11",
true, 1, 101, f4a_1, f4a_1);
452 test_function0_result_type(
"FuncPtr4a_stdlambda_12",
true, 1, 101, f4a_1, f4a_2);
455 INFO(
"Test 00_usage: END");
459 INFO(
"Test 01_member: bind_member<int, TestFunction01, int>: START");
463 MyClassFunction0 f2a_2 =
bind_member(
this, &TestFunction01::func02a_member);
464 test_function0_result_type(
"FuncPtr2a_member_11",
true, 1, 101, f2a_1, f2a_1);
465 test_function0_result_type(
"FuncPtr2a_member_12",
true, 1, 101, f2a_1, f2a_2);
467 MyClassFunction0 f2b_1 =
bind_member(
this, &TestFunction01::func02b_member);
468 MyClassFunction0 f2b_2 =
bind_member(
this, &TestFunction01::func02b_member);
469 test_function0_result_type(
"FuncPtr2b_member_11",
true, 1, 1001, f2b_1, f2b_1);
470 test_function0_result_type(
"FuncPtr2b_member_12",
true, 1, 1001, f2b_1, f2b_2);
472 test_function0_result_type(
"FuncPtr2ab_member_11",
false, 1, 0, f2a_1, f2b_1);
473 test_function0_result_type(
"FuncPtr2ab_member_22",
false, 1, 0, f2a_2, f2b_2);
477 std::string msg =
"member01_c1";
482 int f(
int i)
noexcept {
489 function<int(
int)> f_1a(&c_1a, &c1_t::f);
490 function<int(
int)> f_1b(&c_1b, &c1_t::f);
491 fprintf(stderr,
"%s 1a %s\n", msg.c_str(), f_1a.toString().c_str());
493 fprintf(stderr,
"%s 1b %s\n", msg.c_str(), f_1b.toString().c_str());
498 function<int(
int)> f_2a(&c_2a, &c1_t::f);
499 function<int(
int)> f_2b(&c_2b, &c1_t::f);
500 fprintf(stderr,
"%s 2a %s\n", msg.c_str(), f_2a.toString().c_str());
502 fprintf(stderr,
"%s 2b %s\n", msg.c_str(), f_2b.toString().c_str());
505 test_function0_result_____(msg+
" 1aa", 1, 101, f_1a, f_1a);
506 test_function0_result_____(msg+
" 1ab", 1, 101, f_1a, f_1b);
507 test_function0________type(msg+
" 1aa",
true, f_1a, f_1a);
508 test_function0________type(msg+
" 1ab",
false, f_1a, f_1b);
510 test_function0_result_____(msg+
" 2aa", 1, 1001, f_2a, f_2a);
511 test_function0_result_____(msg+
" 2ab", 1, 1001, f_2a, f_2b);
512 test_function0________type(msg+
" 2aa",
true, f_2a, f_2a);
513 test_function0________type(msg+
" 2ab",
false, f_2a, f_2b);
520 c1_t() : offset(10) {}
521 c1_t(
int v) : offset(v) {}
523 int f(
int i)
noexcept {
529 struct c2_t :
public c1_t {
531 c2_t(
int v) : c1_t(v) {}
533 int f(
int i)
noexcept {
544 std::string msg =
"member02_func_c2";
549 function<int(
int)> f_1a(&c_1a, &c2_t::f);
550 function<int(
int)> f_1b(&c_1b, &c2_t::f);
551 fprintf(stderr,
"%s 1a %s\n", msg.c_str(), f_1a.toString().c_str());
553 fprintf(stderr,
"%s 1b %s\n", msg.c_str(), f_1b.toString().c_str());
556 test_function0_result_____(msg+
" 1aa", 1, 1001, f_1a, f_1a);
557 test_function0_result_____(msg+
" 1ab", 1, 1001, f_1a, f_1b);
558 test_function0________type(msg+
" 1aa",
true, f_1a, f_1a);
559 test_function0________type(msg+
" 1ab",
false, f_1a, f_1b);
567 std::string msg =
"member03_func_c1_ref";
574 function<int(
int)> f_1a(&c_1a, &c1_t::f);
575 function<int(
int)> f_1b(&c_1b, &c1_t::f);
576 fprintf(stderr,
"%s 1a %s\n", msg.c_str(), f_1a.toString().c_str());
578 fprintf(stderr,
"%s 1b %s\n", msg.c_str(), f_1b.toString().c_str());
581 test_function0_result_____(msg+
" 1aa", 1, 101, f_1a, f_1a);
582 test_function0_result_____(msg+
" 1ab", 1, 101, f_1a, f_1b);
583 test_function0________type(msg+
" 1aa",
true, f_1a, f_1a);
584 test_function0________type(msg+
" 1ab",
false, f_1a, f_1b);
592 c1_t() : offset(10) {}
594 int f(
int i)
noexcept {
600 struct c2_t :
public c1_t {
603 c2_t() : c1_t(), offset(20) {}
604 c2_t(
int v) : c1_t(), offset(v) {}
607 struct c3_t :
public c2_t {
609 c3_t(
int v) : c2_t(v) {}
621 function<int(
int)> f_1a(&c_1a, &c1_t::f);
630 std::string msg =
"member04_field_c2";
635 REQUIRE( 1000 == c_1a.offset);
636 fprintf(stderr,
"%s offset: c2_t %d\n", msg.c_str(), c_1a.offset);
638 function<int(
int)> f_1a(&c_1a, &c1_t::f);
639 function<int(
int)> f_1b(&c_1b, &c1_t::f);
640 fprintf(stderr,
"%s 1a %s\n", msg.c_str(), f_1a.toString().c_str());
642 fprintf(stderr,
"%s 1b %s\n", msg.c_str(), f_1b.toString().c_str());
645 test_function0_result_____(msg+
" 1aa", 1, 11, f_1a, f_1a);
646 test_function0_result_____(msg+
" 1ab", 1, 11, f_1a, f_1b);
647 test_function0________type(msg+
" 1aa",
true, f_1a, f_1a);
648 test_function0________type(msg+
" 1ab",
false, f_1a, f_1b);
655 std::string msg =
"member05_field_c1_ref";
662 REQUIRE( 1000 == c_1a_.offset);
663 REQUIRE( 10 == c_1a.offset);
664 fprintf(stderr,
"%s offset: c2_t %d, c1_t ref %d\n", msg.c_str(), c_1a_.offset, c_1a.offset);
666 function<int(
int)> f_1a(&c_1a, &c1_t::f);
667 function<int(
int)> f_1b(&c_1b, &c1_t::f);
668 fprintf(stderr,
"%s 1a %s\n", msg.c_str(), f_1a.toString().c_str());
670 fprintf(stderr,
"%s 1b %s\n", msg.c_str(), f_1b.toString().c_str());
673 test_function0_result_____(msg+
" 1aa", 1, 11, f_1a, f_1a);
674 test_function0_result_____(msg+
" 1ab", 1, 11, f_1a, f_1b);
675 test_function0________type(msg+
" 1aa",
true, f_1a, f_1a);
676 test_function0________type(msg+
" 1ab",
false, f_1a, f_1b);
685 std::string msg =
"member06_vfunc_c1_ref";
690 c1_t() : offset(10) {}
691 c1_t(
int v) : offset(v) {}
693 virtual ~c1_t()
noexcept =
default;
695 virtual int f(
int i)
noexcept {
701 struct c2_t :
public c1_t {
703 c2_t(
int v) : c1_t(v) {}
705 int f(
int i)
noexcept override {
715 function<int(
int)> f_1a(&c_1a, &c1_t::f);
716 function<int(
int)> f_1b(&c_1b, &c1_t::f);
717 fprintf(stderr,
"%s 1a %s\n", msg.c_str(), f_1a.toString().c_str());
719 fprintf(stderr,
"%s 1b %s\n", msg.c_str(), f_1b.toString().c_str());
722 test_function0_result_____(msg+
" 1aa", 1, 1001, f_1a, f_1a);
723 test_function0_result_____(msg+
" 1ab", 1, 1001, f_1a, f_1b);
724 test_function0________type(msg+
" 1aa",
true, f_1a, f_1a);
725 test_function0________type(msg+
" 1ab",
false, f_1a, f_1b);
727 INFO(
"Test 01_member: bind_member<int, TestFunction01, int>: END");
849 INFO(
"Test 04_capval: bindCapture<int, int, int>: START");
853 int offset1000 = 1000;
855 typedef int(*cfunc)(
int&, int);
857 int(*func5a_capture)(
int&, int) = [](
int& capture,
int i)->int {
858 int res = i+10000+capture;
861 int(*func5b_capture)(
int&, int) = [](
int& capture,
int i)->int {
862 int res = i+100000+capture;
867 (cfunc) ( [](
int& capture,
int i)->
int {
868 int res = i+10000+capture;
871 test_function0________type(
"FuncPtr5a_o100_capture_00",
true, f5a_o100_0, f5a_o100_0);
874 MyClassFunction0 f5a_o100_2 =
bind_capval(offset100, func5a_capture);
875 test_function0________type(
"FuncPtr5a_o100_capture_12",
true, f5a_o100_1, f5a_o100_2);
876 test_function0_result_type(
"FuncPtr5a_o100_capture_11",
true, 1, 10101, f5a_o100_1, f5a_o100_1);
877 test_function0_result_type(
"FuncPtr5a_o100_capture_12",
true, 1, 10101, f5a_o100_1, f5a_o100_2);
879 MyClassFunction0 f5a_o1000_1 =
bind_capval(offset1000, func5a_capture);
880 MyClassFunction0 f5a_o1000_2 =
bind_capval(offset1000, func5a_capture);
881 test_function0________type(
"FuncPtr5a_o1000_capture_12",
true, f5a_o1000_1, f5a_o1000_2);
882 test_function0________type(
"FuncPtr5a_o100_o1000_capture_11",
false, f5a_o100_1, f5a_o1000_1);
884 MyClassFunction0 f5b_o100_1 =
bind_capval(offset100, func5b_capture);
885 MyClassFunction0 f5b_o100_2 =
bind_capval(offset100, func5b_capture);
886 test_function0_result_type(
"FuncPtr5b_o100_capture_11",
true, 1, 100101, f5b_o100_1, f5b_o100_1);
887 test_function0_result_type(
"FuncPtr5b_o100_capture_12",
true, 1, 100101, f5b_o100_1, f5b_o100_2);
889 test_function0_result_type(
"FuncPtr5ab_o100_capture_11",
false, 1, 0, f5a_o100_1, f5b_o100_1);
890 test_function0_result_type(
"FuncPtr5ab_o100_capture_22",
false, 1, 0, f5a_o100_2, f5b_o100_2);
891 INFO(
"Test 04_capval: bindCapture<int, int, int>: END");
895 INFO(
"Test 14_capval: bindCapture<int, int, int>: START");
899 int offset1000 = 1000;
901 typedef void(*cfunc)(
int&,
int&, int);
903 void(*func5a_capture)(
int&,
int&, int) = [](
int& capture,
int& res,
int i)->void {
904 res = i+10000+capture;
906 void(*func5b_capture)(
int&,
int&, int) = [](
int& capture,
int& res,
int i)->void {
907 res = i+100000+capture;
911 (cfunc) ( [](
int& capture,
int& res,
int i)->
void {
912 res = i+10000+capture;
914 test_function1________type(
"FuncPtr5a_o100_capture_00",
true, f5a_o100_0, f5a_o100_0);
917 MyClassFunction1 f5a_o100_2 =
bind_capval(offset100, func5a_capture);
918 test_function1________type(
"FuncPtr5a_o100_capture_12",
true, f5a_o100_1, f5a_o100_2);
919 test_function1_result_type(
"FuncPtr5a_o100_capture_11",
true, 1, 10101, f5a_o100_1, f5a_o100_1);
920 test_function1_result_type(
"FuncPtr5a_o100_capture_12",
true, 1, 10101, f5a_o100_1, f5a_o100_2);
922 MyClassFunction1 f5a_o1000_1 =
bind_capval(offset1000, func5a_capture);
923 MyClassFunction1 f5a_o1000_2 =
bind_capval(offset1000, func5a_capture);
924 test_function1________type(
"FuncPtr5a_o1000_capture_12",
true, f5a_o1000_1, f5a_o1000_2);
925 test_function1________type(
"FuncPtr5a_o100_o1000_capture_11",
false, f5a_o100_1, f5a_o1000_1);
927 MyClassFunction1 f5b_o100_1 =
bind_capval(offset100, func5b_capture);
928 MyClassFunction1 f5b_o100_2 =
bind_capval(offset100, func5b_capture);
929 test_function1_result_type(
"FuncPtr5b_o100_capture_11",
true, 1, 100101, f5b_o100_1, f5b_o100_1);
930 test_function1_result_type(
"FuncPtr5b_o100_capture_12",
true, 1, 100101, f5b_o100_1, f5b_o100_2);
932 test_function1_result_type(
"FuncPtr5ab_o100_capture_11",
false, 1, 0, f5a_o100_1, f5b_o100_1);
933 test_function1_result_type(
"FuncPtr5ab_o100_capture_22",
false, 1, 0, f5a_o100_2, f5b_o100_2);
934 INFO(
"Test 14_capval: bindCapture<int, int, int>: END");
938 INFO(
"Test 05_capval: bindCapture<int, std::shared_ptr<IntOffset>, int>: START");
941 std::shared_ptr<IntOffset> offset100(
new IntOffset(100));
942 std::shared_ptr<IntOffset> offset1000(
new IntOffset(1000));
944 typedef int(*cfunc)(std::shared_ptr<IntOffset>&, int);
946 int(*func6a_capture)(std::shared_ptr<IntOffset>&, int) = [](std::shared_ptr<IntOffset>& capture,
int i)->int {
947 int res = i+10000+capture->value;
950 int(*func6b_capture)(std::shared_ptr<IntOffset>&, int) = [](std::shared_ptr<IntOffset>& capture,
int i)->int {
951 int res = i+100000+capture->value;
956 (cfunc) ( [](std::shared_ptr<IntOffset>& sharedOffset,
int i)->int {
957 int res = i+10000+sharedOffset->value;
960 test_function0________type(
"FuncPtr6a_o100_capture_00",
true, f6a_o100_0, f6a_o100_0);
963 MyClassFunction0 f6a_o100_2 =
bind_capval(offset100, func6a_capture);
964 test_function0________type(
"FuncPtr6a_o100_capture_12",
true, f6a_o100_1, f6a_o100_2);
965 test_function0_result_type(
"FuncPtr6a_o100_capture_11",
true, 1, 10101, f6a_o100_1, f6a_o100_1);
966 test_function0_result_type(
"FuncPtr6a_o100_capture_12",
true, 1, 10101, f6a_o100_1, f6a_o100_2);
968 MyClassFunction0 f6a_o1000_1 =
bind_capval(offset1000, func6a_capture);
969 MyClassFunction0 f6a_o1000_2 =
bind_capval(offset1000, func6a_capture);
970 test_function0________type(
"FuncPtr6a_o1000_capture_12",
true, f6a_o1000_1, f6a_o1000_2);
971 test_function0________type(
"FuncPtr6a_o100_o1000_capture_11",
false, f6a_o100_1, f6a_o1000_1);
973 MyClassFunction0 f6b_o100_1 =
bind_capval(offset100, func6b_capture);
974 MyClassFunction0 f6b_o100_2 =
bind_capval(offset100, func6b_capture);
975 test_function0_result_type(
"FuncPtr6b_o100_capture_11",
true, 1, 100101, f6b_o100_1, f6b_o100_1);
976 test_function0_result_type(
"FuncPtr6b_o100_capture_12",
true, 1, 100101, f6b_o100_1, f6b_o100_2);
978 test_function0_result_type(
"FuncPtr6ab_o100_capture_11",
false, 1, 0, f6a_o100_1, f6b_o100_1);
979 test_function0_result_type(
"FuncPtr6ab_o100_capture_22",
false, 1, 0, f6a_o100_2, f6b_o100_2);
980 INFO(
"Test 05_capval: bindCapture<int, std::shared_ptr<IntOffset>, int>: END");
984 INFO(
"Test 06_capval: bindCapture<int, IntOffset, int>: START");
987 IntOffset offset100(100);
988 IntOffset offset1000(1000);
990 typedef int(*cfunc)(IntOffset&, int);
992 int(*func7a_capture)(IntOffset&, int) = [](IntOffset& capture,
int i)->int {
993 int res = i+10000+capture.value;
996 int(*func7b_capture)(IntOffset&, int) = [](IntOffset& capture,
int i)->int {
997 int res = i+100000+capture.value;
1002 (cfunc) ( [](IntOffset& capture,
int i)->
int {
1003 int res = i+10000+capture.value;
1006 test_function0________type(
"FuncPtr7a_o100_capture_00",
true, f7a_o100_0, f7a_o100_0);
1008 INFO(
"f7a_o100_1 copy_ctor");
1010 INFO(
"f7a_o100_1 copy_ctor done");
1011 INFO(
"f7a_o100_2 move_ctor");
1012 MyClassFunction0 f7a_o100_2 =
bind_capval(IntOffset(100), func7a_capture);
1013 INFO(
"f7a_o100_2 move_ctor done");
1014 test_function0________type(
"FuncPtr7a_o100_capture_12",
true, f7a_o100_1, f7a_o100_2);
1015 test_function0_result_type(
"FuncPtr7a_o100_capture_11",
true, 1, 10101, f7a_o100_1, f7a_o100_1);
1016 test_function0_result_type(
"FuncPtr7a_o100_capture_12",
true, 1, 10101, f7a_o100_1, f7a_o100_2);
1018 MyClassFunction0 f7a_o1000_1 =
bind_capval(offset1000, func7a_capture);
1019 MyClassFunction0 f7a_o1000_2 =
bind_capval(offset1000, func7a_capture);
1020 test_function0________type(
"FuncPtr7a_o1000_capture_12",
true, f7a_o1000_1, f7a_o1000_2);
1021 test_function0________type(
"FuncPtr7a_o100_o1000_capture_11",
false, f7a_o100_1, f7a_o1000_1);
1023 MyClassFunction0 f7b_o100_1 =
bind_capval(offset100, func7b_capture);
1024 MyClassFunction0 f7b_o100_2 =
bind_capval(offset100, func7b_capture);
1025 test_function0_result_type(
"FuncPtr7b_o100_capture_11",
true, 1, 100101, f7b_o100_1, f7b_o100_1);
1026 test_function0_result_type(
"FuncPtr7b_o100_capture_12",
true, 1, 100101, f7b_o100_1, f7b_o100_2);
1028 test_function0_result_type(
"FuncPtr7ab_o100_capture_11",
false, 1, 0, f7a_o100_1, f7b_o100_1);
1029 test_function0_result_type(
"FuncPtr7ab_o100_capture_22",
false, 1, 0, f7a_o100_2, f7b_o100_2);
1030 INFO(
"Test 06_capval: bindCapture<int, IntOffset, int>: END");
1034 INFO(
"Test 07_capref: bindCapture<int, IntOffset, int>: START");
1037 IntOffset offset100(100);
1038 IntOffset offset1000(1000);
1040 typedef int(*cfunc)(IntOffset*, int);
1042 int(*func7a_capture)(IntOffset*, int) = [](IntOffset* capture,
int i)->int {
1043 int res = i+10000+capture->value;
1046 int(*func7b_capture)(IntOffset*, int) = [](IntOffset* capture,
int i)->int {
1047 int res = i+100000+capture->value;
1052 (cfunc) ( [](IntOffset* capture,
int i)->
int {
1053 int res = i+10000+capture->value;
1056 test_function0________type(
"FuncPtr7a_o100_capture_00",
true, f7a_o100_0, f7a_o100_0);
1058 INFO(
"f7a_o100_1 copy_ctor");
1060 INFO(
"f7a_o100_1 copy_ctor done");
1061 INFO(
"f7a_o100_2 move_ctor");
1062 MyClassFunction0 f7a_o100_2 =
bind_capref(&offset100, func7a_capture);
1063 INFO(
"f7a_o100_2 move_ctor done");
1064 test_function0________type(
"FuncPtr7a_o100_capture_12",
true, f7a_o100_1, f7a_o100_2);
1065 test_function0_result_type(
"FuncPtr7a_o100_capture_11",
true, 1, 10101, f7a_o100_1, f7a_o100_1);
1066 test_function0_result_type(
"FuncPtr7a_o100_capture_12",
true, 1, 10101, f7a_o100_1, f7a_o100_2);
1068 MyClassFunction0 f7a_o1000_1 =
bind_capref(&offset1000, func7a_capture);
1069 MyClassFunction0 f7a_o1000_2 =
bind_capref(&offset1000, func7a_capture);
1070 test_function0________type(
"FuncPtr7a_o1000_capture_12",
true, f7a_o1000_1, f7a_o1000_2);
1071 test_function0________type(
"FuncPtr7a_o100_o1000_capture_11",
false, f7a_o100_1, f7a_o1000_1);
1073 MyClassFunction0 f7b_o100_1 =
bind_capref(&offset100, func7b_capture);
1074 MyClassFunction0 f7b_o100_2 =
bind_capref(&offset100, func7b_capture);
1075 test_function0_result_type(
"FuncPtr7b_o100_capture_11",
true, 1, 100101, f7b_o100_1, f7b_o100_1);
1076 test_function0_result_type(
"FuncPtr7b_o100_capture_12",
true, 1, 100101, f7b_o100_1, f7b_o100_2);
1078 test_function0_result_type(
"FuncPtr7ab_o100_capture_11",
false, 1, 0, f7a_o100_1, f7b_o100_1);
1079 test_function0_result_type(
"FuncPtr7ab_o100_capture_22",
false, 1, 0, f7a_o100_2, f7b_o100_2);
1080 INFO(
"Test 07_capref: bindCapture<int, IntOffset, int>: END");
1244 volatile int i = 100;
1245 volatile int j = 100;
1247 auto fa0_stub = ( [&](
int a) ->
int {
1251 function<int(
int)> fa0_a( fa0_stub );
1252 fprintf(stderr,
"fa0_a: %s\n", fa0_a.toString().c_str());
1255 auto fa0c_stub = ( [&](
int a) ->
int {
1258 function<int(
int)> fa0_c( fa0c_stub );
1259 fprintf(stderr,
"fa0_c: %s\n", fa0_c.toString().c_str());
1260 fprintf(stderr,
"fa0_stub is_same fa0c_stub: %d\n",
1261 std::is_same_v<
decltype(fa0_stub),
decltype(fa0c_stub)> );
1262 fprintf(stderr,
"fa0_a == fa0_c: %d\n",
1267 function<int(
int)> fa0_b( fa0_stub );
1268 fprintf(stderr,
"fa1: %s\n", fa0_b.toString().c_str());
1271 function<int(
int)> fa2_1 = [&](
int a) ->
int {
1274 fprintf(stderr,
"fa2_1: %s\n", fa2_1.toString().c_str());
1278 function<int(
int)> fa2_2 = lambda_01();
1279 fprintf(stderr,
"fa2_2: %s\n", fa2_2.toString().c_str());
1285 function<int(
int)> fa2_3 = [&](
int a) ->
int {
1288 fprintf(stderr,
"fa2_3: %s\n", fa2_3.toString().c_str());
1292 function<int(
int)> fa2_4 = [i](
int a) ->
int {
1295 fprintf(stderr,
"fa2_4: %s\n", fa2_4.toString().c_str());
1300 function<int(
int)> f_b = [&](
int a) ->
int {
1303 fprintf(stderr,
"f_b: %s\n", f_b.toString().c_str());
1308 function<int(
int)> f_c = [&](
int a) ->
int {
1309 return 2 * ( j + a );
1311 fprintf(stderr,
"f_c: %s\n", f_c.toString().c_str());
1316 function<int(
int)> f_d = [&](
int a) ->
int {
1317 return 2 * ( i + a );
1319 fprintf(stderr,
"f_d: %s\n", f_d.toString().c_str());
1323 function<int(
int,
bool)> f_e = [&](
int a,
bool dummy) ->
int {
1327 fprintf(stderr,
"f_e: %s\n", f_e.toString().c_str());
1330 test_function0_result_type(
"lambda.5b",
true, 1, 101, fa2_1, fa2_1);
1331 test_function0_result_type(
"lambda.5a",
true, 1, 101, fa0_a, fa0_b);
1333 test_function0_result_____(
"lambda.5c", 1, 101, fa2_1, fa2_2);
1334 test_function0________type(
"lambda.5c",
false, fa2_1, fa2_2);
1335 test_function0_result_____(
"lambda.5e", 1, 101, fa2_1, fa2_4);
1336 test_function0________type(
"lambda.5e",
false, fa2_1, fa2_4);
1338 test_function0________type(
"lambda.5B",
false, fa2_1, f_b);
1339 test_function0________type(
"lambda.5C",
false, fa2_1, f_c);
1341 test_function0_result_____(
"lambda.5d", 1, 101, fa2_1, fa2_3);
1343 if( fa2_1 == fa2_3 ) {
1344 fprintf(stderr,
"INFO: limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
1346 fprintf(stderr,
"INFO: limited_lambda_id FIXED: %s:%d\n", __FILE__, __LINE__);
1347 test_function0________type(
"lambda.5d",
false, fa2_1, fa2_3);
1349 if( fa2_1 == f_d ) {
1350 fprintf(stderr,
"INFO: limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
1352 fprintf(stderr,
"INFO: limited_lambda_id FIXED: %s:%d\n", __FILE__, __LINE__);
1353 test_function0________type(
"lambda.5D",
false, fa2_1, f_d);
1356 fprintf(stderr,
"INFO: !limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
1357 test_function0________type(
"lambda.5d",
false, fa2_1, fa2_3);
1358 test_function0________type(
"lambda.5D",
false, fa2_1, f_d);
1360 CHECK(fa2_1 != f_e);
1366 function<int(
int)> f_1 = [&i](
int a) ->
int {
1369 fprintf(stderr,
"l6 f_1 ref: %s\n", f_1.toString().c_str());
1374 function<int(
int)> f_2 = [&j](
int a) ->
int {
1377 fprintf(stderr,
"l6 f_2 ref: %s\n", f_2.toString().c_str());
1380 test_function0_result_____(
"lambda.6", 1, 101, f_1, f_2);
1381 test_function0________type(
"lambda.6",
false, f_1, f_2);
1382 test_function0________type(
"lambda.6",
true, f_1, f_1);
1388 function<int(
int)> f_1 = [&i](
int a) ->
int {
1393 fprintf(stderr,
"l7 f_1 ref: %s\n", f_1.toString().c_str());
1398 function<int(
int)> f_2 = [&j](
int a) ->
int {
1403 fprintf(stderr,
"l7 f_2 ref: %s\n", f_2.toString().c_str());
1406 test_function0_result_copy(
"lambda.7.1a", 1, 101, f_1, f_2);
1407 test_function0_result_copy(
"lambda.7.1b", 1, 102, f_1, f_2);
1408 test_function0_result_copy(
"lambda.7.1c", 1, 103, f_1, f_2);
1410 test_function0_result_____(
"lambda.7.2a", 1, 104, f_1, f_2);
1411 test_function0_result_____(
"lambda.7.2b", 1, 105, f_1, f_2);
1412 test_function0_result_____(
"lambda.7.2c", 1, 106, f_1, f_2);
1414 test_function0________type(
"lambda.7.5",
false, f_1, f_2);
1415 test_function0________type(
"lambda.7.5",
true, f_1, f_1);
1421 function<int(
int)> f_1 = [i](
int a) ->
int {
1424 fprintf(stderr,
"l8 f_1 cpy: %s\n", f_1.toString().c_str());
1429 function<int(
int)> f_2 = [j](
int a) ->
int {
1432 fprintf(stderr,
"l8 f_2 cpy: %s\n", f_2.toString().c_str());
1435 test_function0_result_____(
"lambda.8.1", 1, 101, f_1, f_2);
1437 test_function0________type(
"lambda.8.2",
false, f_1, f_2);
1440 fprintf(stderr,
"INFO: limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
1442 fprintf(stderr,
"INFO: limited_lambda_id FIXED: %s:%d\n", __FILE__, __LINE__);
1443 test_function0________type(
"lambda.8.2",
false, f_1, f_2);
1446 test_function0________type(
"lambda.8.3",
true, f_1, f_1);
1452 function<int(
int)> f_1 = [i](
int a) ->
int {
1453 static int store = i;
1454 int res = store + a;
1458 fprintf(stderr,
"l9 f_1 cpy: %s\n", f_1.toString().c_str());
1463 function<int(
int)> f_2 = [j](
int a) ->
int {
1464 static int store = j;
1465 int res = store + a;
1469 fprintf(stderr,
"l9 f_2 cpy: %s\n", f_2.toString().c_str());
1472 test_function0_result_copy(
"lambda.9.1a", 1, 101, f_1, f_2);
1473 test_function0_result_copy(
"lambda.9.1b", 1, 102, f_1, f_2);
1474 test_function0_result_copy(
"lambda.9.1c", 1, 103, f_1, f_2);
1476 test_function0_result_____(
"lambda.9.2a", 1, 104, f_1, f_2);
1477 test_function0_result_____(
"lambda.9.2b", 1, 105, f_1, f_2);
1478 test_function0_result_____(
"lambda.9.2c", 1, 106, f_1, f_2);
1481 test_function0________type(
"lambda.9.5",
false, f_1, f_2);
1484 fprintf(stderr,
"INFO: limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
1486 fprintf(stderr,
"INFO: limited_lambda_id FIXED: %s:%d\n", __FILE__, __LINE__);
1487 test_function0________type(
"lambda.9.5",
false, f_1, f_2);
1490 test_function0________type(
"lambda.9.5",
true, f_1, f_1);
1499 function<int(
int)> f_1 = [i](
int a)
mutable ->
int {
1504 fprintf(stderr,
"l10 f_1 cpy: %s\n", f_1.toString().c_str());
1509 function<int(
int)> f_2 = [j](
int a)
mutable ->
int {
1514 fprintf(stderr,
"l10 f_2 cpy: %s\n", f_2.toString().c_str());
1517#if FUNCTIONAL_IMPL == 1
1518 test_function0_result_copy(
"lambda.10.1a", 1, 101, f_1, f_2);
1519 test_function0_result_copy(
"lambda.10.1b", 1, 101, f_1, f_2);
1520 test_function0_result_copy(
"lambda.10.1c", 1, 101, f_1, f_2);
1522 fprintf(stderr,
"l10 f_2 cpy: FUNCTIONAL_BROKEN_COPY_WITH_MUTABLE_LAMBDA\n");
1525 test_function0_result_____(
"lambda.10.2a", 1, 101, f_1, f_2);
1526 test_function0_result_____(
"lambda.10.2b", 1, 102, f_1, f_2);
1527 test_function0_result_____(
"lambda.10.2c", 1, 103, f_1, f_2);
1530 test_function0________type(
"lambda.10.5",
false, f_1, f_2);
1533 fprintf(stderr,
"INFO: limited_lambda_id: %s:%d\n", __FILE__, __LINE__);
1535 fprintf(stderr,
"INFO: limited_lambda_id FIXED: %s:%d\n", __FILE__, __LINE__);
1536 test_function0________type(
"lambda.10.5",
false, f_1, f_2);
1539 test_function0________type(
"lambda.10.5",
true, f_1, f_1);
1541#if ( FUNCTIONAL_IMPL == 1 )
1543 function<int(
int)> f_1 =
function<int(
int)>::bind_ylambda( [](
auto& self,
int x) ->
int {
1547 return x * self(x-1);
1550 fprintf(stderr,
"ylambda 1 f_1: %s\n", f_1.toString().c_str());
1552 REQUIRE( 24 == f_1(4) );
1555 function<int(
int)> f_2 =
function<int(
int)>::bind_ylambda( [](
auto& self,
int x) ->
int {
1559 return x * self(x-1);
1562 test_function0________type(
"ylambda.1.1",
true, f_1, f_1);
1563 test_function0________type(
"ylambda.1.2",
false, f_1, f_2);