Skip to content

Wrap .connect callback (delegates and lambdas) #1211

Answered by skypjack
gergovari asked this question in Q&A
Discussion options

You must be logged in to vote

Sorry for the late reply. I'm a little busy due to personal issues. 🙏
The point is that delegates receive their callbacks as template arguments. You can't have lambdas in this case (well, you can have non-capturing lambdas with C++20, but it's technically a pointer to a free function at the end of the day).
Therefore, what you were trying to do in your first example wasn't possible. The last one gets the job done instead.

Consider that the whole signal support is a storage mixin in EnTT. Something you can swap off as you like. You can also replace it with your own implementation that works with lambdas if you prefer, it's also pretty easy to code I guess.
I decided to use delegates becaus…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@gergovari
Comment options

Answer selected by gergovari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
discussion it sounds interesting, let's discuss it
2 participants