@@ -168,17 +168,34 @@ namespace etl
168168 }
169169 };
170170
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 const bool value = etl::is_base_of<delegate_tag, T>::value;
186+ };
187+
171188 // *************************************************************************
172189 // / Declaration.
173190 // *************************************************************************
174191 template <typename T>
175192 class delegate ;
176193
177194 template <typename TReturn, typename TParam>
178- class delegate <TReturn(TParam)> : public private_delegate::call_if_impl<delegate<TReturn(TParam)>, TReturn, TParam>
195+ class delegate <TReturn(TParam)> : public private_delegate::call_if_impl<delegate<TReturn(TParam)>, TReturn, TParam>, public delegate_tag
179196 {
180197 private:
181-
198+
182199 typedef delegate<TReturn(TParam)> delegate_type;
183200
184201 public:
@@ -204,7 +221,7 @@ namespace etl
204221 // Construct from a functor.
205222 // *************************************************************************
206223 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 )
208225 {
209226 assign ((void *)(&instance), functor_stub<TFunctor>);
210227 }
@@ -213,7 +230,7 @@ namespace etl
213230 // Construct from a const functor.
214231 // *************************************************************************
215232 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 )
217234 {
218235 assign ((void *)(&instance), const_functor_stub<TFunctor>);
219236 }
@@ -232,7 +249,7 @@ namespace etl
232249 // *************************************************************************
233250 template <typename TFunctor>
234251 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
236253 create (TFunctor& instance)
237254 {
238255 return delegate ((void *)(&instance), functor_stub<TFunctor>);
@@ -243,7 +260,7 @@ namespace etl
243260 // *************************************************************************
244261 template <typename TFunctor>
245262 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
247264 create (const TFunctor& instance)
248265 {
249266 return delegate ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -330,7 +347,7 @@ namespace etl
330347 // / Set from Functor.
331348 // *************************************************************************
332349 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
334351 set (TFunctor& instance)
335352 {
336353 assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -340,7 +357,7 @@ namespace etl
340357 // / Set from const Functor.
341358 // *************************************************************************
342359 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
344361 set (const TFunctor& instance)
345362 {
346363 assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -467,7 +484,7 @@ namespace etl
467484 // / Create from Functor.
468485 // *************************************************************************
469486 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
471488 operator =(TFunctor& instance)
472489 {
473490 assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -478,7 +495,7 @@ namespace etl
478495 // / Create from const Functor.
479496 // *************************************************************************
480497 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
482499 operator =(const TFunctor& instance)
483500 {
484501 assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -705,7 +722,7 @@ namespace etl
705722 // Construct from functor.
706723 // *************************************************************************
707724 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 )
709726 {
710727 assign ((void *)(&instance), functor_stub<TFunctor>);
711728 }
@@ -714,7 +731,7 @@ namespace etl
714731 // Construct from const functor.
715732 // *************************************************************************
716733 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 )
718735 {
719736 assign ((void *)(&instance), const_functor_stub<TFunctor>);
720737 }
@@ -733,7 +750,7 @@ namespace etl
733750 // *************************************************************************
734751 template <typename TFunctor>
735752 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
737754 create (TFunctor& instance)
738755 {
739756 return delegate ((void *)(&instance), functor_stub<TFunctor>);
@@ -744,7 +761,7 @@ namespace etl
744761 // *************************************************************************
745762 template <typename TFunctor>
746763 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
748765 create (const TFunctor& instance)
749766 {
750767 return delegate ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -831,7 +848,7 @@ namespace etl
831848 // / Set from Functor.
832849 // *************************************************************************
833850 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
835852 set (TFunctor& instance)
836853 {
837854 assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -841,7 +858,7 @@ namespace etl
841858 // / Set from const Functor.
842859 // *************************************************************************
843860 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
845862 set (const TFunctor& instance)
846863 {
847864 assign ((void *)(&instance), const_functor_stub<TFunctor>);
@@ -968,7 +985,7 @@ namespace etl
968985 // / Create from Functor.
969986 // *************************************************************************
970987 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
972989 operator =(TFunctor& instance)
973990 {
974991 assign ((void *)(&instance), functor_stub<TFunctor>);
@@ -979,7 +996,7 @@ namespace etl
979996 // / Create from const Functor.
980997 // *************************************************************************
981998 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
9831000 operator =(const TFunctor& instance)
9841001 {
9851002 assign ((void *)(&instance), const_functor_stub<TFunctor>);
0 commit comments