Skip to content

Commit 8eaeb86

Browse files
authored
Merge pull request #3244 from geky/callback-type-relaxation
callback - Relax type-deduction in callback class
2 parents 5750f31 + 9c0c95a commit 8eaeb86

File tree

2 files changed

+529
-2138
lines changed

2 files changed

+529
-2138
lines changed

TESTS/mbed_functional/callback/main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ template <typename T>
233233
T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4)
234234
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
235235

236+
// Inheriting class
237+
template <typename T>
238+
class Thing2 : public Thing<T> {
239+
};
240+
236241

237242
// function call and result verification
238243
template <typename T>
@@ -315,15 +320,18 @@ struct Verifier {
315320
template <typename T>
316321
void test_dispatch0() {
317322
Thing<T> thing;
323+
Thing2<T> thing2;
318324
Verifier<T>::verify0(static_func0<T>);
319325
Verifier<T>::verify0(&thing, &Thing<T>::member_func0);
320326
Verifier<T>::verify0((const Thing<T>*)&thing, &Thing<T>::const_member_func0);
321327
Verifier<T>::verify0((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func0);
322328
Verifier<T>::verify0((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func0);
329+
Verifier<T>::verify0(&thing2, &Thing2<T>::member_func0);
323330
Verifier<T>::verify0(&bound_func0<T>, &thing);
324331
Verifier<T>::verify0(&const_bound_func0<T>, (const Thing<T>*)&thing);
325332
Verifier<T>::verify0(&volatile_bound_func0<T>, (volatile Thing<T>*)&thing);
326333
Verifier<T>::verify0(&const_volatile_bound_func0<T>, (const volatile Thing<T>*)&thing);
334+
Verifier<T>::verify0(&bound_func0<T>, &thing2);
327335
Verifier<T>::verify0(&void_func0<T>, &thing);
328336
Verifier<T>::verify0(&const_void_func0<T>, (const Thing<T>*)&thing);
329337
Verifier<T>::verify0(&volatile_void_func0<T>, (volatile Thing<T>*)&thing);
@@ -342,15 +350,18 @@ void test_dispatch0() {
342350
template <typename T>
343351
void test_dispatch1() {
344352
Thing<T> thing;
353+
Thing2<T> thing2;
345354
Verifier<T>::verify1(static_func1<T>);
346355
Verifier<T>::verify1(&thing, &Thing<T>::member_func1);
347356
Verifier<T>::verify1((const Thing<T>*)&thing, &Thing<T>::const_member_func1);
348357
Verifier<T>::verify1((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func1);
349358
Verifier<T>::verify1((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func1);
359+
Verifier<T>::verify1(&thing2, &Thing2<T>::member_func1);
350360
Verifier<T>::verify1(&bound_func1<T>, &thing);
351361
Verifier<T>::verify1(&const_bound_func1<T>, (const Thing<T>*)&thing);
352362
Verifier<T>::verify1(&volatile_bound_func1<T>, (volatile Thing<T>*)&thing);
353363
Verifier<T>::verify1(&const_volatile_bound_func1<T>, (const volatile Thing<T>*)&thing);
364+
Verifier<T>::verify1(&bound_func1<T>, &thing2);
354365
Verifier<T>::verify1(&void_func1<T>, &thing);
355366
Verifier<T>::verify1(&const_void_func1<T>, (const Thing<T>*)&thing);
356367
Verifier<T>::verify1(&volatile_void_func1<T>, (volatile Thing<T>*)&thing);
@@ -369,15 +380,18 @@ void test_dispatch1() {
369380
template <typename T>
370381
void test_dispatch2() {
371382
Thing<T> thing;
383+
Thing2<T> thing2;
372384
Verifier<T>::verify2(static_func2<T>);
373385
Verifier<T>::verify2(&thing, &Thing<T>::member_func2);
374386
Verifier<T>::verify2((const Thing<T>*)&thing, &Thing<T>::const_member_func2);
375387
Verifier<T>::verify2((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func2);
376388
Verifier<T>::verify2((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func2);
389+
Verifier<T>::verify2(&thing2, &Thing2<T>::member_func2);
377390
Verifier<T>::verify2(&bound_func2<T>, &thing);
378391
Verifier<T>::verify2(&const_bound_func2<T>, (const Thing<T>*)&thing);
379392
Verifier<T>::verify2(&volatile_bound_func2<T>, (volatile Thing<T>*)&thing);
380393
Verifier<T>::verify2(&const_volatile_bound_func2<T>, (const volatile Thing<T>*)&thing);
394+
Verifier<T>::verify2(&bound_func2<T>, &thing2);
381395
Verifier<T>::verify2(&void_func2<T>, &thing);
382396
Verifier<T>::verify2(&const_void_func2<T>, (const Thing<T>*)&thing);
383397
Verifier<T>::verify2(&volatile_void_func2<T>, (volatile Thing<T>*)&thing);
@@ -396,15 +410,18 @@ void test_dispatch2() {
396410
template <typename T>
397411
void test_dispatch3() {
398412
Thing<T> thing;
413+
Thing2<T> thing2;
399414
Verifier<T>::verify3(static_func3<T>);
400415
Verifier<T>::verify3(&thing, &Thing<T>::member_func3);
401416
Verifier<T>::verify3((const Thing<T>*)&thing, &Thing<T>::const_member_func3);
402417
Verifier<T>::verify3((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func3);
403418
Verifier<T>::verify3((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func3);
419+
Verifier<T>::verify3(&thing2, &Thing2<T>::member_func3);
404420
Verifier<T>::verify3(&bound_func3<T>, &thing);
405421
Verifier<T>::verify3(&const_bound_func3<T>, (const Thing<T>*)&thing);
406422
Verifier<T>::verify3(&volatile_bound_func3<T>, (volatile Thing<T>*)&thing);
407423
Verifier<T>::verify3(&const_volatile_bound_func3<T>, (const volatile Thing<T>*)&thing);
424+
Verifier<T>::verify3(&bound_func3<T>, &thing2);
408425
Verifier<T>::verify3(&void_func3<T>, &thing);
409426
Verifier<T>::verify3(&const_void_func3<T>, (const Thing<T>*)&thing);
410427
Verifier<T>::verify3(&volatile_void_func3<T>, (volatile Thing<T>*)&thing);
@@ -423,15 +440,18 @@ void test_dispatch3() {
423440
template <typename T>
424441
void test_dispatch4() {
425442
Thing<T> thing;
443+
Thing2<T> thing2;
426444
Verifier<T>::verify4(static_func4<T>);
427445
Verifier<T>::verify4(&thing, &Thing<T>::member_func4);
428446
Verifier<T>::verify4((const Thing<T>*)&thing, &Thing<T>::const_member_func4);
429447
Verifier<T>::verify4((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func4);
430448
Verifier<T>::verify4((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func4);
449+
Verifier<T>::verify4(&thing2, &Thing2<T>::member_func4);
431450
Verifier<T>::verify4(&bound_func4<T>, &thing);
432451
Verifier<T>::verify4(&const_bound_func4<T>, (const Thing<T>*)&thing);
433452
Verifier<T>::verify4(&volatile_bound_func4<T>, (volatile Thing<T>*)&thing);
434453
Verifier<T>::verify4(&const_volatile_bound_func4<T>, (const volatile Thing<T>*)&thing);
454+
Verifier<T>::verify4(&bound_func4<T>, &thing2);
435455
Verifier<T>::verify4(&void_func4<T>, &thing);
436456
Verifier<T>::verify4(&const_void_func4<T>, (const Thing<T>*)&thing);
437457
Verifier<T>::verify4(&volatile_void_func4<T>, (volatile Thing<T>*)&thing);
@@ -450,15 +470,18 @@ void test_dispatch4() {
450470
template <typename T>
451471
void test_dispatch5() {
452472
Thing<T> thing;
473+
Thing2<T> thing2;
453474
Verifier<T>::verify5(static_func5<T>);
454475
Verifier<T>::verify5(&thing, &Thing<T>::member_func5);
455476
Verifier<T>::verify5((const Thing<T>*)&thing, &Thing<T>::const_member_func5);
456477
Verifier<T>::verify5((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func5);
457478
Verifier<T>::verify5((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func5);
479+
Verifier<T>::verify5(&thing2, &Thing2<T>::member_func5);
458480
Verifier<T>::verify5(&bound_func5<T>, &thing);
459481
Verifier<T>::verify5(&const_bound_func5<T>, (const Thing<T>*)&thing);
460482
Verifier<T>::verify5(&volatile_bound_func5<T>, (volatile Thing<T>*)&thing);
461483
Verifier<T>::verify5(&const_volatile_bound_func5<T>, (const volatile Thing<T>*)&thing);
484+
Verifier<T>::verify5(&bound_func5<T>, &thing2);
462485
Verifier<T>::verify5(&void_func5<T>, &thing);
463486
Verifier<T>::verify5(&const_void_func5<T>, (const Thing<T>*)&thing);
464487
Verifier<T>::verify5(&volatile_void_func5<T>, (volatile Thing<T>*)&thing);

0 commit comments

Comments
 (0)