using FUNC_DOIT = bool(*)(string &sDll, string &sMessage, WPARAM &wParam, LPARAM &lParam);
Będę przypisywał teraz adresy metod i nie wiem jak przerobić powyższy kod, aby FUNC_DOIT była wskaźnikiem na metodę.
Potrafię to zrobić za pomocą typedef ale kiedyś ktoś powiedział, że bardziej eleganckie używanie using w C++.
Macie jakieś pomysły?
Czy to będzie:
using FUNC_DOIT = bool(cPLUGIN::*)(string &sDll, string &sMessage, WPARAM &wParam, LPARAM &lParam);
Jeżeli tak, to dlaczego nie działa mi lambda:
FUNC_DOIT foo = NULL;
foo = [this](string &sDll, string &sMessage, WPARAM &wParam, LPARAM &lParam)->bool{
string sM = ">> Call Message: \n";
sM += "> PluginCreateSucces( "; sM += (const char*)lParam; sM += " )\n";
f_Console_AddLine(sM);
return true;
};
mDoIt["INFO__PLUGIN_CREATE_SUCCES"] = foo;
błędy:
=== Build: Release in MainWindow (compiler: GNU GCC Compiler) ===|
In member function 'void cPLUGIN::f_FillMessages()':|
|50|error: cannot convert 'cPLUGIN::f_FillMessages()::__lambda0' to 'FUNC_DOIT {aka bool ()(std::basic_string<char>&, std::basic_string<char>&, unsigned int&, long int&)}' in assignment|
|57|error: cannot convert 'cPLUGIN::f_FillMessages()::__lambda1' to 'std::map<std::basic_string<char>, bool ()(std::basic_string<char>&, std::basic_string<char>&, unsigned int&, long int&)>::mapped_type {aka bool ()(std::basic_string<char>&, std::basic_string<char>&, unsigned int&, long int&)}' in assignment|
|60|error: cannot convert 'cPLUGIN::f_FillMessages()::__lambda2' to 'std::map<std::basic_string<char>, bool ()(std::basic_string<char>&, std::basic_string<char>&, unsigned int&, long int&)>::mapped_type {aka bool ()(std::basic_string<char>&, std::basic_string<char>&, unsigned int&, long int&)}' in assignment|
|63|error: cannot convert 'cPLUGIN::f_FillMessages()::__lambda3' to 'std::map<std::basic_string<char>, bool ()(std::basic_string<char>&, std::basic_string<char>&, unsigned int&, long int&)>::mapped_type {aka bool (*)(std::basic_string<char>&, std::basic_string<char>&, unsigned int&, long int&)}' in assignment|
== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===