dimanche 6 décembre 2015

Convert lambda to function pointer

So I am trying to convert a lambda to a function pointer to make it compatible with a rather archaic function like so

void* (* temp) (void*) = (void* (*) (void*)) [] (void* arg) {
    TempData* temp_data = (TempData*) arg;
    temp_data->func();
    return NULL;
};

But I keep getting the error

error: cannot cast from type '(lambda at test.cpp:30:54)' to pointer type 'void *(*)(void *)'

Could someone tell me how I can fix this problem?

Aucun commentaire:

Enregistrer un commentaire