Skip to content

Commit 9a460a2

Browse files
committed
bugfix of variadic in Cuts constructor
1 parent e0bc82c commit 9a460a2

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

infra/Cuts.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,4 @@ void Cuts::AddCuts(const std::vector<SimpleCut>& cuts) {
8888
}
8989
}
9090

91-
template<typename... Args>
92-
Cuts::Cuts(std::string name, Args... args) : name_(std::move(name)) {
93-
// AddCuts(std::forward<Args>(args)...);
94-
AddCuts(args...);
95-
}
96-
97-
template<typename T, typename... Args>
98-
void Cuts::AddCuts(const T& t, const Args&... args) {
99-
AddCuts(t);
100-
AddCuts(args...);
101-
}
102-
10391
}// namespace AnalysisTree

infra/Cuts.hpp

+16-4
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,27 @@ class Cuts {
4848
}
4949
}
5050

51-
template<typename... Args>
52-
explicit Cuts(std::string name, Args... args);
53-
5451
void AddCut(const SimpleCut& cut);
5552

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

55+
// Base case for variadic recursion (handles when there's just one argument left)
56+
template<typename T>
57+
void AddCuts(const T& t) {
58+
AddCuts(t); // Call the appropriate overload for a single argument (like std::vector<SimpleCut>)
59+
}
60+
61+
// Recursive case for variadic template (multiple arguments)
5862
template<typename T, typename... Args>
59-
void AddCuts(const T& t, const Args&... args);
63+
void AddCuts(const T& t, const Args&... args) {
64+
AddCuts(t);
65+
AddCuts(args...);
66+
}
67+
68+
template<typename... Args>
69+
Cuts(std::string name, Args... args) : name_(std::move(name)) {
70+
AddCuts(args...);
71+
}
6072

6173
/**
6274
* @brief Evaluates all SimpleCuts

infra/TaskManager.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ TaskManager* TaskManager::GetInstance() {
2222

2323
void TaskManager::Init(const std::vector<std::string>& filelists, const std::vector<std::string>& in_trees) {
2424
assert(!is_init_);
25+
std::cout << "TaskManager::Init()\n";
2526
is_init_ = true;
2627
read_in_tree_ = true;
2728
chain_ = new Chain(filelists, in_trees);
@@ -51,6 +52,7 @@ void TaskManager::InitTasks() {
5152

5253
void TaskManager::Init() {
5354
assert(!is_init_);
55+
std::cout << "TaskManager::Init()\n";
5456
is_init_ = true;
5557
fill_out_tree_ = true;
5658

0 commit comments

Comments
 (0)