Skip to content

Commit e33342d

Browse files
author
John Wellbelove
committed
Fixed conditional compilation
Added ability to use call_if when using etl::delegate as the slot_type # Conflicts: # include/etl/signal.h
1 parent a9bce6f commit e33342d

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

include/etl/signal.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ namespace etl
120120
{
121121
for (const slot_type& s : *this)
122122
{
123-
call(s, etl::forward<TArgs>(args)...);
123+
if (valid(s))
124+
{
125+
s(etl::forward<TArgs>(args)...);
126+
}
124127
}
125128
}
126129

@@ -220,23 +223,25 @@ namespace etl
220223
iterator end_of_list;
221224

222225
//*************************************************************************
223-
/// For a delegate slot type, use call_if.
226+
/// For a delegate slot type.
224227
//*************************************************************************
225228
template <typename TSlotType, typename... TArgs>
226-
typename etl::enable_if_t<etl::is_delegate<TSlotType>::value, void>
227-
call(const TSlotType& s, TArgs&&... args) const
229+
static
230+
typename etl::enable_if_t<etl::is_delegate<TSlotType>::value, bool>
231+
valid(const TSlotType& s)
228232
{
229-
s.call_if(etl::forward<TArgs>(args)...);
233+
return s.is_valid();
230234
}
231235

232236
//*************************************************************************
233-
/// For a non-delegate slot type, just call the slot.
237+
/// For a non-delegate slot type.
234238
//*************************************************************************
235239
template <typename TSlotType, typename... TArgs>
236-
typename etl::enable_if_t<!etl::is_delegate<TSlotType>::value, void>
237-
call(const TSlotType& s, TArgs&&... args) const
240+
static
241+
typename etl::enable_if_t<!etl::is_delegate<TSlotType>::value, bool>
242+
valid(const TSlotType& s, TArgs&&... args)
238243
{
239-
s(etl::forward<TArgs>(args)...);
244+
return true;
240245
}
241246

242247
//*************************************************************************

0 commit comments

Comments
 (0)