Closed VladimirP1 closed 1 month ago
Thanks, I'll take a look at that when I get back from Spain later this week.
No other use, I simply did not want to pollute the namespace with additional classes
Should I replace delegate<void>
with a tag class?
Yes, I think so.
It may be good to make a traits class.
template
Just thought of another addition.
etl::is_delegate_v
definition.
For C++17 only.
I should be able to process this pull request tomorrow afternoon.
Original problem, how to reproduce:
This compiles and does not look suspicious at the first glance but results in a segmentation fault at runtime.
What happens here: 1) A delegate is created
etl::delegate<void(ctx::any ctx)>::create<Test, &Test::CbAnyCtx>(*this);
2) But we need a etl::delegate<void(ctx::os ctx)>, the compiler selects the constructor fromconst TLambda&
. 3) Note thatetl::is_same<etl::delegate<TReturn(TParams...)>, TLambda>::value
is false because the signatures of the delegates do not match 4) The newly created delegate is returned and the first delegate is destroyed. Now the second delegate holds a dangling pointerThis PR attempts to fix this issue by using a reliable method for checking if a functor is a delegate