@@ -39,6 +39,17 @@ namespace events {
39
39
*/
40
40
#define EVENTS_QUEUE_SIZE (32 *EVENTS_EVENT_SIZE)
41
41
42
+ namespace impl {
43
+ /* C++20 type identity */
44
+ template <typename T>
45
+ struct type_identity {
46
+ using type = T;
47
+ };
48
+
49
+ template <typename T>
50
+ using type_identity_t = typename type_identity<T>::type;
51
+ }
52
+
42
53
// Predeclared classes
43
54
template <typename F>
44
55
class Event ;
@@ -498,8 +509,8 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
498
509
*/
499
510
// AStyle ignore, not handling correctly below
500
511
// *INDENT-OFF*
501
- template <typename R, typename ...BoundArgs, typename ...ContextArgs, typename ... Args>
502
- Event<void (Args...)> event (R (*func)(BoundArgs..., Args...), ContextArgs ...context_args);
512
+ template <typename R, typename ...BoundArgs, typename ...Args>
513
+ Event<void (Args...)> event (R (*func)(BoundArgs..., Args...), BoundArgs ...context_args);
503
514
// *INDENT-ON*
504
515
505
516
/* * Creates an event bound to the event queue
@@ -546,8 +557,8 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
546
557
*/
547
558
// AStyle ignore, not handling correctly below
548
559
// *INDENT-OFF*
549
- template <typename T, typename R, typename ...BoundArgs, typename ...ContextArgs, typename ... Args>
550
- Event<void (Args...)> event (T *obj, R (T::*method)(BoundArgs..., Args...), ContextArgs ...context_args);
560
+ template <typename T, typename R, typename ...BoundArgs, typename ...Args>
561
+ Event<void (Args...)> event (T *obj, R (T::*method)(BoundArgs..., Args...), BoundArgs ...context_args);
551
562
// *INDENT-ON*
552
563
553
564
/* * Creates an event bound to the event queue
@@ -585,8 +596,8 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
585
596
* }
586
597
* @endcode
587
598
*/
588
- template <typename R, typename ...BoundArgs, typename ...ContextArgs, typename ... Args>
589
- Event<void (Args...)> event (mbed::Callback<R(BoundArgs..., Args...)> cb, ContextArgs ...context_args);
599
+ template <typename R, typename ...BoundArgs, typename ...Args>
600
+ Event<void (Args...)> event (mbed::Callback<R(BoundArgs..., Args...)> cb, BoundArgs ...context_args);
590
601
591
602
#else
592
603
@@ -650,7 +661,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
650
661
* @see EventQueue::call
651
662
*/
652
663
template <typename T, typename R, typename ... ArgTs>
653
- int call (T *obj, R(T::*method)(ArgTs...), ArgTs... args)
664
+ int call (T *obj, R(T::*method)(ArgTs...), impl::type_identity_t< ArgTs> ... args)
654
665
{
655
666
return call (mbed::callback (obj, method), args...);
656
667
}
@@ -659,7 +670,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
659
670
* @see EventQueue::call
660
671
*/
661
672
template <typename T, typename R, typename ... ArgTs>
662
- int call (const T *obj, R(T::*method)(ArgTs...) const , ArgTs... args)
673
+ int call (const T *obj, R(T::*method)(ArgTs...) const , impl::type_identity_t< ArgTs> ... args)
663
674
{
664
675
return call (mbed::callback (obj, method), args...);
665
676
}
@@ -668,7 +679,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
668
679
* @see EventQueue::call
669
680
*/
670
681
template <typename T, typename R, typename ... ArgTs>
671
- int call (volatile T *obj, R(T::*method)(ArgTs...) volatile, ArgTs... args)
682
+ int call (volatile T *obj, R(T::*method)(ArgTs...) volatile, impl::type_identity_t< ArgTs> ... args)
672
683
{
673
684
return call (mbed::callback (obj, method), args...);
674
685
}
@@ -677,7 +688,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
677
688
* @see EventQueue::call
678
689
*/
679
690
template <typename T, typename R, typename ... ArgTs>
680
- int call (const volatile T *obj, R(T::*method)(ArgTs...) const volatile, ArgTs... args)
691
+ int call (const volatile T *obj, R(T::*method)(ArgTs...) const volatile, impl::type_identity_t< ArgTs> ... args)
681
692
{
682
693
return call (mbed::callback (obj, method), args...);
683
694
}
@@ -726,7 +737,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
726
737
* @see EventQueue::call_in
727
738
*/
728
739
template <typename T, typename R, typename ... ArgTs>
729
- int call_in (int ms, T *obj, R(T::*method)(ArgTs...), ArgTs... args)
740
+ int call_in (int ms, T *obj, R(T::*method)(ArgTs...), impl::type_identity_t< ArgTs> ... args)
730
741
{
731
742
return call_in (ms, mbed::callback (obj, method), args...);
732
743
}
@@ -735,7 +746,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
735
746
* @see EventQueue::call_in
736
747
*/
737
748
template <typename T, typename R, typename ... ArgTs>
738
- int call_in (int ms, const T *obj, R(T::*method)(ArgTs...) const , ArgTs... args)
749
+ int call_in (int ms, const T *obj, R(T::*method)(ArgTs...) const , impl::type_identity_t< ArgTs> ... args)
739
750
{
740
751
return call_in (ms, mbed::callback (obj, method), args...);
741
752
}
@@ -744,7 +755,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
744
755
* @see EventQueue::call_in
745
756
*/
746
757
template <typename T, typename R, typename ... ArgTs>
747
- int call_in (int ms, volatile T *obj, R(T::*method)(ArgTs...) volatile, ArgTs... args)
758
+ int call_in (int ms, volatile T *obj, R(T::*method)(ArgTs...) volatile, impl::type_identity_t< ArgTs> ... args)
748
759
{
749
760
return call_in (ms, mbed::callback (obj, method), args...);
750
761
}
@@ -753,7 +764,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
753
764
* @see EventQueue::call_in
754
765
*/
755
766
template <typename T, typename R, typename ... ArgTs>
756
- int call_in (int ms, const volatile T *obj, R(T::*method)(ArgTs...) const volatile, ArgTs... args)
767
+ int call_in (int ms, const volatile T *obj, R(T::*method)(ArgTs...) const volatile, impl::type_identity_t< ArgTs> ... args)
757
768
{
758
769
return call_in (ms, mbed::callback (obj, method), args...);
759
770
}
@@ -806,7 +817,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
806
817
* @see EventQueue::call_every
807
818
*/
808
819
template <typename T, typename R, typename ... ArgTs>
809
- int call_every (int ms, T *obj, R(T::*method)(ArgTs...), ArgTs... args)
820
+ int call_every (int ms, T *obj, R(T::*method)(ArgTs...), impl::type_identity_t< ArgTs> ... args)
810
821
{
811
822
return call_every (ms, mbed::callback (obj, method), args...);
812
823
}
@@ -815,7 +826,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
815
826
* @see EventQueue::call_every
816
827
*/
817
828
template <typename T, typename R, typename ... ArgTs>
818
- int call_every (int ms, const T *obj, R(T::*method)(ArgTs...) const , ArgTs... args)
829
+ int call_every (int ms, const T *obj, R(T::*method)(ArgTs...) const , impl::type_identity_t< ArgTs> ... args)
819
830
{
820
831
return call_every (ms, mbed::callback (obj, method), args...);
821
832
}
@@ -824,7 +835,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
824
835
* @see EventQueue::call_every
825
836
*/
826
837
template <typename T, typename R, typename ... ArgTs>
827
- int call_every (int ms, volatile T *obj, R(T::*method)(ArgTs...) volatile, ArgTs... args)
838
+ int call_every (int ms, volatile T *obj, R(T::*method)(ArgTs...) volatile, impl::type_identity_t< ArgTs> ... args)
828
839
{
829
840
return call_every (ms, mbed::callback (obj, method), args...);
830
841
}
@@ -833,7 +844,7 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
833
844
* @see EventQueue::call_every
834
845
*/
835
846
template <typename T, typename R, typename ... ArgTs>
836
- int call_every (int ms, const volatile T *obj, R(T::*method)(ArgTs...) const volatile, ArgTs... args)
847
+ int call_every (int ms, const volatile T *obj, R(T::*method)(ArgTs...) const volatile, impl::type_identity_t< ArgTs> ... args)
837
848
{
838
849
return call_every (ms, mbed::callback (obj, method), args...);
839
850
}
@@ -847,38 +858,38 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
847
858
* @param func Function to execute when the event is dispatched
848
859
* @return Event that will dispatch on the specific queue
849
860
*/
850
- template <typename R, typename ... BoundArgTs, typename ... ContextArgTs, typename ... ArgTs>
851
- Event<void (ArgTs...)> event (R(*func)(BoundArgTs..., ArgTs...), ContextArgTs ... context_args);
861
+ template <typename R, typename ... BoundArgTs, typename ... ArgTs>
862
+ Event<void (ArgTs...)> event (R(*func)(BoundArgTs..., ArgTs...), impl::type_identity_t<BoundArgTs> ... context_args);
852
863
853
864
/* * Creates an event bound to the event queue
854
865
* @see EventQueue::event
855
866
*/
856
- template <typename T, typename R, typename ... BoundArgTs, typename ... ContextArgTs, typename ... ArgTs>
857
- Event<void (ArgTs...)> event (T *obj, R(T::*method)(BoundArgTs..., ArgTs...), ContextArgTs ... context_args);
867
+ template <typename T, typename R, typename ... BoundArgTs, typename ... ArgTs>
868
+ Event<void (ArgTs...)> event (T *obj, R(T::*method)(BoundArgTs..., ArgTs...), impl::type_identity_t<BoundArgTs> ... context_args);
858
869
859
870
/* * Creates an event bound to the event queue
860
871
* @see EventQueue::event
861
872
*/
862
- template <typename T, typename R, typename ... BoundArgTs, typename ... ContextArgTs, typename ... ArgTs>
863
- Event<void (ArgTs...)> event (const T *obj, R(T::*method)(BoundArgTs..., ArgTs...) const , ContextArgTs ... context_args);
873
+ template <typename T, typename R, typename ... BoundArgTs, typename ... ArgTs>
874
+ Event<void (ArgTs...)> event (const T *obj, R(T::*method)(BoundArgTs..., ArgTs...) const , impl::type_identity_t<BoundArgTs> ... context_args);
864
875
865
876
/* * Creates an event bound to the event queue
866
877
* @see EventQueue::event
867
878
*/
868
- template <typename T, typename R, typename ... BoundArgTs, typename ... ContextArgTs, typename ... ArgTs>
869
- Event<void (ArgTs...)> event (volatile T *obj, R(T::*method)(BoundArgTs..., ArgTs...) volatile, ContextArgTs ... context_args);
879
+ template <typename T, typename R, typename ... BoundArgTs, typename ... ArgTs>
880
+ Event<void (ArgTs...)> event (volatile T *obj, R(T::*method)(BoundArgTs..., ArgTs...) volatile, impl::type_identity_t<BoundArgTs> ... context_args);
870
881
871
882
/* * Creates an event bound to the event queue
872
883
* @see EventQueue::event
873
884
*/
874
- template <typename T, typename R, typename ... BoundArgTs, typename ... ContextArgTs, typename ... ArgTs>
875
- Event<void (ArgTs...)> event (const volatile T *obj, R(T::*method)(BoundArgTs..., ArgTs...) const volatile, ContextArgTs ... context_args);
885
+ template <typename T, typename R, typename ... BoundArgTs, typename ... ArgTs>
886
+ Event<void (ArgTs...)> event (const volatile T *obj, R(T::*method)(BoundArgTs..., ArgTs...) const volatile, impl::type_identity_t<BoundArgTs> ... context_args);
876
887
877
888
/* * Creates an event bound to the event queue
878
889
* @see EventQueue::event
879
890
*/
880
- template <typename R, typename ... BoundArgTs, typename ... ContextArgTs, typename ... ArgTs>
881
- Event<void (ArgTs...)> event (mbed::Callback<R(BoundArgTs..., ArgTs...)> cb, ContextArgTs ... context_args);
891
+ template <typename R, typename ... BoundArgTs, typename ... ArgTs>
892
+ Event<void (ArgTs...)> event (mbed::Callback<R(BoundArgTs..., ArgTs...)> cb, impl::type_identity_t<BoundArgTs> ... context_args);
882
893
#endif
883
894
884
895
protected:
0 commit comments