Skip to content

Commit 8cb858a

Browse files
committed
[DF] User-friendly error in case of Fill signature mismatch
E.g. in this scenario: ```cpp struct Filler { void Fill(int) {} void Merge(const std::vector<Filler *> &) {} }; int main() { ROOT::RDataFrame(2).Define("x", [] { return 42; }).Fill<int, int>(Filler{}, {"x", "x"}); } ```
1 parent 475ec62 commit 8cb858a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tree/dataframe/inc/ROOT/RDF/ActionHelpers.hxx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,14 +453,14 @@ public:
453453

454454
// no container arguments
455455
template <typename... ValTypes, std::enable_if_t<!Disjunction<IsDataContainer<ValTypes>...>::value, int> = 0>
456-
void Exec(unsigned int slot, const ValTypes &...x)
456+
auto Exec(unsigned int slot, const ValTypes &...x) -> decltype(fObjects[slot]->Fill(x...), void())
457457
{
458458
fObjects[slot]->Fill(x...);
459459
}
460460

461461
// at least one container argument
462462
template <typename... Xs, std::enable_if_t<Disjunction<IsDataContainer<Xs>...>::value, int> = 0>
463-
void Exec(unsigned int slot, const Xs &...xs)
463+
auto Exec(unsigned int slot, const Xs &...xs) -> decltype(fObjects[slot]->Fill(*MakeBegin(xs)...), void())
464464
{
465465
// array of bools keeping track of which inputs are containers
466466
constexpr std::array<bool, sizeof...(Xs)> isContainer{IsDataContainer<Xs>::value...};
@@ -485,6 +485,14 @@ public:
485485
ExecLoop<colidx>(slot, xrefend, MakeBegin(xs)...);
486486
}
487487

488+
template <typename T = HIST>
489+
void Exec(...)
490+
{
491+
static_assert(sizeof(T) < 0,
492+
"When filling an object with RDataFrame (e.g. via a Fill action) the number or types of the "
493+
"columns passed did not match the signature of the object's `Fill` method.");
494+
}
495+
488496
void Initialize() { /* noop */}
489497

490498
void Finalize()

0 commit comments

Comments
 (0)