@@ -168,21 +168,42 @@ 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 : etl::bool_constant<etl::is_base_of<delegate_tag, T>::value>
184
+ {
185
+ };
186
+
171
187
// *************************************************************************
172
188
// / Declaration.
173
189
// *************************************************************************
174
190
template <typename T>
175
191
class delegate ;
176
192
177
193
template <typename TReturn, typename TParam>
178
- class delegate <TReturn(TParam)> : public private_delegate::call_if_impl<delegate<TReturn(TParam)>, TReturn, TParam>
194
+ class delegate <TReturn(TParam)> : public private_delegate::call_if_impl<delegate<TReturn(TParam)>, TReturn, TParam>,
195
+ public delegate_tag
179
196
{
180
197
private:
181
-
198
+
182
199
typedef delegate<TReturn(TParam)> delegate_type;
183
200
184
201
public:
185
202
203
+ typedef TReturn (*function_type)(TParam);
204
+ typedef TReturn return_type;
205
+ typedef TParam argument_type;
206
+
186
207
using private_delegate::call_if_impl<delegate<TReturn(TParam)>, TReturn, TParam>::call_if;
187
208
188
209
// *************************************************************************
@@ -204,7 +225,7 @@ namespace etl
204
225
// Construct from a functor.
205
226
// *************************************************************************
206
227
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 )
228
+ delegate (TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, int >::type = 0 )
208
229
{
209
230
assign ((void *)(&instance), functor_stub<TFunctor>);
210
231
}
@@ -213,7 +234,7 @@ namespace etl
213
234
// Construct from a const functor.
214
235
// *************************************************************************
215
236
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 )
237
+ delegate (const TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, int >::type = 0 )
217
238
{
218
239
assign ((void *)(&instance), const_functor_stub<TFunctor>);
219
240
}
@@ -232,7 +253,7 @@ namespace etl
232
253
// *************************************************************************
233
254
template <typename TFunctor>
234
255
static
235
- typename etl::enable_if<etl::is_class<TFunctor>::value &&!etl::is_same<delegate_type, TFunctor>::value, delegate>::type
256
+ typename etl::enable_if<etl::is_class<TFunctor>::value &&!is_delegate< TFunctor>::value, delegate>::type
236
257
create (TFunctor& instance)
237
258
{
238
259
return delegate ((void *)(&instance), functor_stub<TFunctor>);
@@ -243,7 +264,7 @@ namespace etl
243
264
// *************************************************************************
244
265
template <typename TFunctor>
245
266
static
246
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
267
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate>::type
247
268
create (const TFunctor& instance)
248
269
{
249
270
return delegate ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -330,7 +351,7 @@ namespace etl
330
351
// / Set from Functor.
331
352
// *************************************************************************
332
353
template <typename TFunctor>
333
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void >::type
354
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, void >::type
334
355
set (TFunctor& instance)
335
356
{
336
357
assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -340,7 +361,7 @@ namespace etl
340
361
// / Set from const Functor.
341
362
// *************************************************************************
342
363
template <typename TFunctor>
343
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void >::type
364
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, void >::type
344
365
set (const TFunctor& instance)
345
366
{
346
367
assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -467,7 +488,7 @@ namespace etl
467
488
// / Create from Functor.
468
489
// *************************************************************************
469
490
template <typename TFunctor>
470
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
491
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate&>::type
471
492
operator =(TFunctor& instance)
472
493
{
473
494
assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -478,7 +499,7 @@ namespace etl
478
499
// / Create from const Functor.
479
500
// *************************************************************************
480
501
template <typename TFunctor>
481
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
502
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate&>::type
482
503
operator =(const TFunctor& instance)
483
504
{
484
505
assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -684,6 +705,10 @@ namespace etl
684
705
685
706
public:
686
707
708
+ typedef TReturn (*function_type)(void );
709
+ typedef TReturn return_type;
710
+ typedef void argument_type;
711
+
687
712
using private_delegate::call_if_impl< delegate<TReturn(void )>, TReturn, void >::call_if;
688
713
689
714
// *************************************************************************
@@ -705,7 +730,7 @@ namespace etl
705
730
// Construct from functor.
706
731
// *************************************************************************
707
732
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 )
733
+ delegate (TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, int >::type = 0 )
709
734
{
710
735
assign ((void *)(&instance), functor_stub<TFunctor>);
711
736
}
@@ -714,7 +739,7 @@ namespace etl
714
739
// Construct from const functor.
715
740
// *************************************************************************
716
741
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 )
742
+ delegate (const TFunctor& instance, typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, int >::type = 0 )
718
743
{
719
744
assign ((void *)(&instance), const_functor_stub<TFunctor>);
720
745
}
@@ -733,7 +758,7 @@ namespace etl
733
758
// *************************************************************************
734
759
template <typename TFunctor>
735
760
static
736
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
761
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate>::type
737
762
create (TFunctor& instance)
738
763
{
739
764
return delegate ((void *)(&instance), functor_stub<TFunctor>);
@@ -744,7 +769,7 @@ namespace etl
744
769
// *************************************************************************
745
770
template <typename TFunctor>
746
771
static
747
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate>::type
772
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate>::type
748
773
create (const TFunctor& instance)
749
774
{
750
775
return delegate ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -831,7 +856,7 @@ namespace etl
831
856
// / Set from Functor.
832
857
// *************************************************************************
833
858
template <typename TFunctor>
834
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void >::type
859
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, void >::type
835
860
set (TFunctor& instance)
836
861
{
837
862
assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -841,7 +866,7 @@ namespace etl
841
866
// / Set from const Functor.
842
867
// *************************************************************************
843
868
template <typename TFunctor>
844
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, void >::type
869
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, void >::type
845
870
set (const TFunctor& instance)
846
871
{
847
872
assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -968,7 +993,7 @@ namespace etl
968
993
// / Create from Functor.
969
994
// *************************************************************************
970
995
template <typename TFunctor>
971
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
996
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate&>::type
972
997
operator =(TFunctor& instance)
973
998
{
974
999
assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -979,7 +1004,7 @@ namespace etl
979
1004
// / Create from const Functor.
980
1005
// *************************************************************************
981
1006
template <typename TFunctor>
982
- typename etl::enable_if<etl::is_class<TFunctor>::value && !etl::is_same<delegate_type, TFunctor>::value, delegate&>::type
1007
+ typename etl::enable_if<etl::is_class<TFunctor>::value && !is_delegate< TFunctor>::value, delegate&>::type
983
1008
operator =(const TFunctor& instance)
984
1009
{
985
1010
assign ((void *)(&instance), const_functor_stub<TFunctor>);
0 commit comments