0
votes

I get this error:

IntelliSense: no suitable conversion function from "lambda []void (Form::Form *arg1)->void" to "Form::OnLoad" exists c:\users\topkek\desktop\project\test\tset\test\main.cpp

Real error:

Error 8 error C2440: 'type cast' : cannot convert from '`anonymous-namespace'::' to 'Form::OnLoad' c:\users\topkek\desktop\project\test\tset\tes‌​t\main.cpp

This is the code:

new Form::Form("TEST_MAIN", "Test main", (Form::OnLoad)[](Form::Form* arg1)->void {

form.h:

typedef void(*OnLoad)(Form*);
Form(const char* WindowClass, const char* Title, OnLoad Func = NULL);

Form.cpp:

Form::Form(const char* szWindowClass, const char* Title, OnLoad Func) {
1
IntelliSense messages are not considered "real" error messages. Can you compile the code and post the "real" error message from the compiler please? - Rakete1111
Error 8 error C2440: 'type cast' : cannot convert from '`anonymous-namespace'::<lambda0>' to 'Form::OnLoad' c:\users\topkek\desktop\project\test\tset\test\main.cpp - Arix

1 Answers

0
votes
(Form::OnLoad)[](Form::Form* arg1)->void { /*...*/ })

That is one weird lambda :)

I'm not sure what exactly you are trying to do, but you don't need a lambda for this:

auto f = new Form::Form("TEST_MAIN", "Test main", &Form::OnLoad);
                                                  ^^^^^^^^^^^^^
                                                  Address of function

If you want a lambda, drop the start:

auto f = new Form::Form("TEST_MAIN", "Test main", [](Form::Form* arg1)->void {});