@@ -168,6 +168,23 @@ namespace etl
168
168
}
169
169
};
170
170
171
+ // *****************************************************************
172
+ // / The tag to identify an etl::delegate.
173
+ // /\ingroup delegate
174
+ // *****************************************************************
175
+ struct delegate_tag
176
+ {
177
+ };
178
+
179
+ // ***************************************************************************
180
+ // / is_delegate
181
+ // ***************************************************************************
182
+ template <typename T>
183
+ struct is_delegate
184
+ {
185
+ static constexpr bool value = etl::is_base_of<delegate_tag, T>::value;
186
+ };
187
+
171
188
// *************************************************************************
172
189
// / Declaration.
173
190
// *************************************************************************
@@ -204,7 +221,7 @@ namespace etl
204
221
// Construct from a functor.
205
222
// *************************************************************************
206
223
template <typename TFunctor>
207
- delegate (TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, int >::type = 0 )
224
+ delegate (TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, int >::type = 0 )
208
225
{
209
226
assign ((void *)(&instance), functor_stub<TFunctor>);
210
227
}
@@ -213,7 +230,7 @@ namespace etl
213
230
// Construct from a const functor.
214
231
// *************************************************************************
215
232
template <typename TFunctor>
216
- delegate (const TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, int >::type = 0 )
233
+ delegate (const TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, int >::type = 0 )
217
234
{
218
235
assign ((void *)(&instance), const_functor_stub<TFunctor>);
219
236
}
@@ -232,7 +249,7 @@ namespace etl
232
249
// *************************************************************************
233
250
template <typename TFunctor>
234
251
static
235
- typename etl::enable_if<etl::is_class<TFunctor>::value &&!etl::is_same<delegate_type, TFunctor>::value, delegate>::type
252
+ typename etl::enable_if<etl::is_class<TFunctor>::value &&!is_delegate< TFunctor>::value, delegate>::type
236
253
create (TFunctor& instance)
237
254
{
238
255
return delegate ((void *)(&instance), functor_stub<TFunctor>);
@@ -243,7 +260,7 @@ namespace etl
243
260
// *************************************************************************
244
261
template <typename TFunctor>
245
262
static
246
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
263
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate>::type
247
264
create (const TFunctor& instance)
248
265
{
249
266
return delegate ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -330,7 +347,7 @@ namespace etl
330
347
// / Set from Functor.
331
348
// *************************************************************************
332
349
template <typename TFunctor>
333
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void >::type
350
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, void >::type
334
351
set (TFunctor& instance)
335
352
{
336
353
assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -340,7 +357,7 @@ namespace etl
340
357
// / Set from const Functor.
341
358
// *************************************************************************
342
359
template <typename TFunctor>
343
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void >::type
360
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, void >::type
344
361
set (const TFunctor& instance)
345
362
{
346
363
assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -467,7 +484,7 @@ namespace etl
467
484
// / Create from Functor.
468
485
// *************************************************************************
469
486
template <typename TFunctor>
470
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
487
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate&>::type
471
488
operator =(TFunctor& instance)
472
489
{
473
490
assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -478,7 +495,7 @@ namespace etl
478
495
// / Create from const Functor.
479
496
// *************************************************************************
480
497
template <typename TFunctor>
481
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
498
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate&>::type
482
499
operator =(const TFunctor& instance)
483
500
{
484
501
assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -705,7 +722,7 @@ namespace etl
705
722
// Construct from functor.
706
723
// *************************************************************************
707
724
template <typename TFunctor>
708
- delegate (TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, int >::type = 0 )
725
+ delegate (TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, int >::type = 0 )
709
726
{
710
727
assign ((void *)(&instance), functor_stub<TFunctor>);
711
728
}
@@ -714,7 +731,7 @@ namespace etl
714
731
// Construct from const functor.
715
732
// *************************************************************************
716
733
template <typename TFunctor>
717
- delegate (const TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, int >::type = 0 )
734
+ delegate (const TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, int >::type = 0 )
718
735
{
719
736
assign ((void *)(&instance), const_functor_stub<TFunctor>);
720
737
}
@@ -733,7 +750,7 @@ namespace etl
733
750
// *************************************************************************
734
751
template <typename TFunctor>
735
752
static
736
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
753
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate>::type
737
754
create (TFunctor& instance)
738
755
{
739
756
return delegate ((void *)(&instance), functor_stub<TFunctor>);
@@ -744,7 +761,7 @@ namespace etl
744
761
// *************************************************************************
745
762
template <typename TFunctor>
746
763
static
747
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
764
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate>::type
748
765
create (const TFunctor& instance)
749
766
{
750
767
return delegate ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -831,7 +848,7 @@ namespace etl
831
848
// / Set from Functor.
832
849
// *************************************************************************
833
850
template <typename TFunctor>
834
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void >::type
851
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, void >::type
835
852
set (TFunctor& instance)
836
853
{
837
854
assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -841,7 +858,7 @@ namespace etl
841
858
// / Set from const Functor.
842
859
// *************************************************************************
843
860
template <typename TFunctor>
844
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void >::type
861
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, void >::type
845
862
set (const TFunctor& instance)
846
863
{
847
864
assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -968,7 +985,7 @@ namespace etl
968
985
// / Create from Functor.
969
986
// *************************************************************************
970
987
template <typename TFunctor>
971
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
988
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate&>::type
972
989
operator =(TFunctor& instance)
973
990
{
974
991
assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -979,7 +996,7 @@ namespace etl
979
996
// / Create from const Functor.
980
997
// *************************************************************************
981
998
template <typename TFunctor>
982
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
999
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate&>::type
983
1000
operator =(const TFunctor& instance)
984
1001
{
985
1002
assign ((void *)(&instance), const_functor_stub<TFunctor>);
0 commit comments