ROOT Version: 6.16.00
Platform: linux (cc7)
Compiler: gcc 4.8.5
Hi everybody,
Assume I have a functor ‘func’ with various overloaded operator() which only differ in the argument list (type or number or arguments). I’d like to call this functor in different ways to add new columns to my dataframe like in the following snippet:
auto d2 = d.Define(“res1”, func, {“x”}); // calling operator()(int)
.Define(“res2”, func, {“x”, “y”}); // calling operator()(int, int)
However the forwarding to the specific function doesn’t work. I tried to follow a bit this blog:
https://blog.tartanllama.xyz/passing-overload-sets/
I admit, most of this I don’t know or understand in much detail.
The only way I could solve this problem so far is by using lambda functions as follows:
auto d2 = d.Define(“res1”, [&feval](int x) -> int { return feval(x); }, {“x”});
.Define(“res2”, [&feval](int x, int y) -> int { return feval(x, y); }, {“x”, “y”});
Is there a more elegant way with or without using lambda functions? Maybe a way where the entire declaration of the function is not required? I could get the example working of the above link.
Many thanks in advance.
Kai
The only way I could get this