Skip to content

[Hist] Generalize TF1 constructor using C++17 #19203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025

Conversation

guitargeek
Copy link
Contributor

Before, the requirement was that the wrapped function had a call operator that exactly took C-style arrays as arguments.

To be more general, we check if the function can be invoked with C-style arrays as arguments, even if implicit conversions are involved. This is done using std::is_invocable_r_v from C++17.

Care was taken that the detection of vectorized functions still works, which can be tested like this (requires veccore and vc):

// Modified reproducer from ROOT-10251
auto originalFF = [](ROOT::Double_v *x , double *par){ (void)par; return *x; };
auto boundFF = std::bind (originalFF,std::placeholders::_1, std::placeholders::_2);
TF1 myFitFunct("myFitFunct", boundFF,0, 1 , 0 );

myFitFunct.Print("v");

std::cout << myFitFunct.IsVectorized() << std::endl;

Closes https://its.cern.ch/jira/browse/ROOT-10251.

Before, the requirement was that the wrapped function had a call
operator that *exactly* took C-style arrays as arguments.

To be more general, we check if the function can be invoked with C-style
arrays as arguments, even if implicit conversions are involved. This is
done using `std::is_invocable_r_v` from C++17.

Care was taken that the detection of vectorized functions still works,
which can be tested like this (requires `veccore` and `vc`):

```c++
// Modified reproducer from ROOT-10251
auto originalFF = [](ROOT::Double_v *x , double *par){ (void)par; return *x; };
auto boundFF = std::bind (originalFF,std::placeholders::_1, std::placeholders::_2);
TF1 myFitFunct("myFitFunct", boundFF,0, 1 , 0 );

myFitFunct.Print("v");

std::cout << myFitFunct.IsVectorized() << std::endl;
```

Closes https://its.cern.ch/jira/browse/ROOT-10251.
@guitargeek guitargeek self-assigned this Jun 26, 2025
@guitargeek guitargeek requested a review from lmoneta as a code owner June 26, 2025 22:50
@guitargeek guitargeek requested a review from dpiparo June 27, 2025 06:40
Copy link

Test Results

    20 files      20 suites   3d 22h 40m 56s ⏱️
 3 050 tests  3 050 ✅ 0 💤 0 ❌
59 400 runs  59 400 ✅ 0 💤 0 ❌

Results for commit 49085ee.

@guitargeek guitargeek merged commit 8c1bdee into root-project:master Jun 27, 2025
24 of 25 checks passed
@guitargeek guitargeek deleted the ROOT-10251 branch June 27, 2025 13:33
@atolosadelgado
Copy link
Contributor

Thank you @guitargeek !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants