Please read tips for efficient and successful posting and posting code
ROOT Version: 6.26/08
Platform: CentOS7
Compiler: GCC 11
This might be a niche, but valid C++ usage that I noticed does not hold well in PyROOT environment. Essentially I have some template class which I would like to enable member functions based on what type T
it holds. In my full implementation I also place some requirements on the input arguments types but below is a minimal example of just the former consideration:
import ROOT
ROOT.gInterpreter.Declare(
'''
template <typename T>
struct MyContainer
{
template <typename... Args, typename U = T, typename std::enable_if_t<std::is_arithmetic_v<U>,U>* = nullptr>
auto onlyForNumbers(Args... args)
{
((std::cout << args << std::endl),...);
}
};
'''
)
myContainer = ROOT.MyContainer['double']()
myContainer.onlyForNumbers(1.0,2.0,3.0)
The above C++ source works fine both when statically compiled or called as a root macro. However, PyROOT seems to have trouble with it with the following error message:
input_line_34:6:33: error: no matching member function for call to 'onlyForNumbers'
((MyContainer<double>*)obj)->onlyForNumbers<double, double, double, double, nullptr>(*(double*)args[0], *(double*)args[1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
input_line_32:6:8: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Args'
auto onlyForNumbers(Args... args)
^
Am I making a mistake here, or is it a (known?) limitation of PyROOT/cppyy? Thank you for any help in advance!