Hi all,
I’d like to create a column containing a vector of a custom type, but the program fails on execution:
% ./a.out
input_line_14:4:184: error: use of undeclared identifier 'Product'
namespace __rdf1 { using products5_type = void /* The type of column "products" (Product) is not known to the interpreter. */; }namespace __rdf1 { using moreproducts6_type = vector<Product>; }
^
terminate called after throwing an instance of 'std::runtime_error'
what():
An error occurred while jitting. The lines above might indicate the cause of the crash
zsh: abort ./a.out
If I remove the last Define
, i.e. create a column of just the custom type, it works. What am I doing wrong?
Cheers,
Jonas
#include <ROOT/RDataFrame.hxx>
#include <iostream>
class Product
{
public:
Product() : _x(0), _y(0) {}
Product(double x, double y) : _x(x), _y(y) {}
~Product() {}
void PrintProduct() {
std::cout << _x*_y << std::endl;
}
private:
double _x, _y;
};
int main(int argc, char* argv[])
{
auto df = ROOT::RDataFrame(10)
.Define("x", "1.")
.Define("y", "2.")
.Define("products", [](double x, double y) {return Product(x, y);}, {"x", "y"})
.Define("moreproducts", [](double x, double y) {return std::vector<Product>(10, Product(x, y));}, {"x", "y"});
df.Foreach([](Product& p) {p.PrintProduct();}, {"products"});
return 0;
}
_ROOT Version: 6.18.00
_Platform: Scientific Linux 6, x86_64
Compiler: g++ 8.2.0