Our delegates don’t currently have explicit support for lambdas, however, since a lambda that doesn’t capture anything will convert to a static function pointer, some lambdas will still work.
Your lambda doesn’t work since it’s capturing Event.
What you could do instead is not capture Event, but rather bind it to the delegate and take it as a parameter (this works for any kind of function bound to a delegate, not just lambdas).
HttpRequest->OnProcessRequestComplete().BindStatic([](FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded, FTheEventType Event)
{
int a = 100; // Just to see if this is gonna compile
}, Event);
However I need to pass an extra object (my analytics event itself) to the OnRequestComplete method (to handle a failed connection scenario) so I thought I could use a lambda expression and capture my event:
HttpRequest->OnProcessRequestComplete().BindRaw(this, [Event](FHttpRequestPtr HttpRequest, FHttpResponsePtr HttpResponse, bool bSucceeded)
{
int a = 100; // Just to see if this is gonna compile
});
And of course this didn’t work (otherwise I wouldn’t ask this question)
Actually I tried to compile my lambda without capturing Event and it didn’t work either (same error message). But you’re absolutely right - I can just pass payload while binding my delegate! It solves my problem - thank you, Jamie!