// This works fine
auto shiftIndexCallback {
[](ImGuiInputTextCallbackData *data) -> int
{ ... }
}
// This will not compile
int a,b,c;
auto shiftIndexCapturingCallback {
[a,b,c](ImGuiInputTextCallbackData *data) -> int
{ ... }
}
// Being used as parameter to specify a callback
if (ImGui::InputTextWithHint("##library_search_str", hint.c_str(), library_search_str, sizeof(library_search_str)
, ImGuiInputTextFlags_CallbackEdit
, shiftIndexCapturingCallback
)
) { ... }
The compile error I get (linux g++);
error: cannot convert ‘Foo::bar()::<lambda(ImGuiInputTextCallbackData*)>’ to ‘ImGuiInputTextCallback’ {aka ‘int (*)(ImGuiInputTextCallbackData*)’}
1205 | , shiftIndexCapturingCallback
| ^~~~~~~~~~~~~~~~~~
| |
| BoardView::MainMenu()::<lambda(ImGuiInputTextCallbackData*)>
I'm presuming I need to use something like std::function perhaps ?