ROOT Version: 6.22/08
Platform: Ubuntu 20.04 under WSL2
Compiler: gcc 9.3.0
Warning : issue is a non-priority (I suppose that I know how to solve it, but in a somewhat unpleasant way)
I tried to pass lambda with some capture list into TF1, but it didn’t work for me no matter how I try.
Following fails due to compilation error saying that TF1 cannot be constructed this way
Double_t par1 = 0, par2 = 2;
auto fit_lamb = [=](Double_t* x) {return par1 + x[0] * par2; };
TF1* fit = new TF1("fit", fit_lamb, 0, 6, 2);
Following
Double_t par1 = 0, par2 = 2;
auto fit_lamb = [=](Double_t* x) {return par1 + x[0] * par2; };
TF1* fit = new TF1("fit", "fit_lamb(x)", 0, 6);
fails at the execution time
input_line_12:2:66: error: use of undeclared identifier 'fit_lamb'
Double_t TFormula____id10424473659609012643(Double_t *x){ return fit_lamb(x[0]) ; }
^
input_line_13:2:66: error: use of undeclared identifier 'fit_lamb'
Double_t TFormula____id10424473659609012643(Double_t *x){ return fit_lamb(x[0]) ; }
^
Error in <prepareMethod>: Can't compile function TFormula____id10424473659609012643 prototype with arguments Double_t*
Error in <TFormula::InputFormulaIntoCling>: Error compiling formula expression in Cling
Error in <TFormula::ProcessFormula>: Formula "fit_lamb(x)" is invalid !
...
An obvious solution is to pass whole capture list as a parameter list, but I find this solution not so elegant. What is the intended way of solving this issue?
Thanks in advance for any help.