Skip to content

Commit

Permalink
bugfix of variadic in Cuts constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
lubynets committed Feb 11, 2025
1 parent e0bc82c commit 9a460a2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
12 changes: 0 additions & 12 deletions infra/Cuts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,4 @@ void Cuts::AddCuts(const std::vector<SimpleCut>& cuts) {
}
}

template<typename... Args>
Cuts::Cuts(std::string name, Args... args) : name_(std::move(name)) {
// AddCuts(std::forward<Args>(args)...);
AddCuts(args...);
}

template<typename T, typename... Args>
void Cuts::AddCuts(const T& t, const Args&... args) {
AddCuts(t);
AddCuts(args...);
}

}// namespace AnalysisTree
20 changes: 16 additions & 4 deletions infra/Cuts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,27 @@ class Cuts {
}
}

template<typename... Args>
explicit Cuts(std::string name, Args... args);

void AddCut(const SimpleCut& cut);

void AddCuts(const std::vector<SimpleCut>& cuts);

// Base case for variadic recursion (handles when there's just one argument left)
template<typename T>
void AddCuts(const T& t) {
AddCuts(t); // Call the appropriate overload for a single argument (like std::vector<SimpleCut>)
}

// Recursive case for variadic template (multiple arguments)
template<typename T, typename... Args>
void AddCuts(const T& t, const Args&... args);
void AddCuts(const T& t, const Args&... args) {
AddCuts(t);
AddCuts(args...);
}

template<typename... Args>
Cuts(std::string name, Args... args) : name_(std::move(name)) {
AddCuts(args...);
}

/**
* @brief Evaluates all SimpleCuts
Expand Down
2 changes: 2 additions & 0 deletions infra/TaskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ TaskManager* TaskManager::GetInstance() {

void TaskManager::Init(const std::vector<std::string>& filelists, const std::vector<std::string>& in_trees) {
assert(!is_init_);
std::cout << "TaskManager::Init()\n";
is_init_ = true;
read_in_tree_ = true;
chain_ = new Chain(filelists, in_trees);
Expand Down Expand Up @@ -51,6 +52,7 @@ void TaskManager::InitTasks() {

void TaskManager::Init() {
assert(!is_init_);
std::cout << "TaskManager::Init()\n";
is_init_ = true;
fill_out_tree_ = true;

Expand Down

0 comments on commit 9a460a2

Please sign in to comment.