implot
implot copied to clipboard
Lambda support is advertised and documented, but apparently not implemented.
In ImPlot 0.14, PlotLineG
(or any other getter-enabled function) does not implement a lambda getter argument. The only getter defined is a c-style function pointer named ImPlotGetter
and lambdas are not convertible to c-style function pointers. Is this an oversight in the documentation or the implementation?
they are 'convertible' when they have this signature: auto my_lambda = [](int idx, void*) { ... }
but it confused me as well, and could be improved imo - see #445
The conversion of non-capturing lambdas to function pointers is a compiler feature though, and not a library feature. So the library de-facto does not support lambdas.
What would be your use-case? your make lambdas which capture your data and return the transformed data you want to plot? or captureless lambdas taking a data* and index? or third option?
Your first option, e.g.,
auto getter = [t, y](int idx, void *unused) -> ImPlotPoint {
return ImPlotPoint(t[idx], y[idx].x);
};
instead of having to create a struct containing t and y, and passing in a pointer to that struct.