diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index 60e0df45c..a2975d758 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -1014,15 +1014,16 @@ std::string Caller::counters(int action) { if (args.empty()) { WrongNumberOfParameters(1); } - if (std::any_of(args.cbegin(), args.cend(), [](std::string s) { - return (StringTo(s) < 0 || StringTo(s) > 2); + //convert args to string and then to a vector of ints + auto counters = StringTo>( ToString(args)); + if (std::any_of(counters.cbegin(), counters.cend(), [](int val) { + return (val < 0 || val > 2); })) { throw RuntimeError("Invalid counter indices list. Example: 0 1 2"); } // convert vector to counter enable mask uint32_t mask = 0; - for (size_t i = 0; i < args.size(); ++i) { - int val = StringTo(args[i]); + for (auto val : counters) { // already enabled earlier if (mask & (1 << val)) { std::ostringstream oss;