jeudi 17 décembre 2020

Map C++ lambda function with capture list to a function parameter

I have a C++ function that takes another function as a parameter. When I use this function I pass it a lambda function with a capture list. This works fine until I attempt to add items to the capture list. When I do it says it can't convert the lambda to the same syntax as the function (hopefully that made sense).

Function Declaration:

SYMCXRESULT Configure(MyManager *manager, void (*completionHandler)(MyResponse * response)) noexcept;

Lambda Call:

Configure(manager, [=](MyResponse * response) -> void {
            object->functionCall();
        });

Error Message:

No viable conversion from '(lambda at /path/file.mm:370:67)' to 'void (*)(MyResponse *__strong)'

Aucun commentaire:

Enregistrer un commentaire