Skip to content

Commit 72e9c65

Browse files
committed
fix compiler errors
Signed-off-by: Eduard Fried <eduard.fried@soptim.de>
1 parent 289cd04 commit 72e9c65

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include <exception>
1111
#include <format>
12-
#include <numeric>
1312
#include <sstream>
1413
#include <string>
1514
#include <utility>
@@ -181,14 +180,9 @@ class UnsupportedRegulatorCombinationError : public PowerGridError {
181180

182181
class ConflictingVoltageRegulatorURef : public PowerGridError {
183182
public:
184-
ConflictingVoltageRegulatorURef(std::vector<ID> const& regulator_ids)
183+
ConflictingVoltageRegulatorURef(std::string const& regulator_ids)
185184
: PowerGridError{
186-
std::format("Conflicting u_ref values detected for voltage regulators {}.",
187-
std::accumulate(std::next(regulator_ids.begin()), regulator_ids.end(),
188-
std::to_string(regulator_ids[0]),
189-
[](std::string a, ID b) { return a + ", " + std::to_string(b); }
190-
)
191-
)} {}
185+
std::format("Conflicting u_ref values detected for voltage regulators {}.", regulator_ids)} {}
192186
};
193187

194188
class AutomaticTapCalculationError : public PowerGridError {

power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,15 @@ class MainModelImpl {
554554
}
555555
}
556556
if (!conflicting_regulators.empty()) {
557-
throw ConflictingVoltageRegulatorURef{conflicting_regulators};
557+
// join IDs like this, because of various compiler errors with std::format and
558+
// std::accumulate when used in exception constructor
559+
std::ostringstream oss;
560+
for (size_t i = 0; i < conflicting_regulators.size(); ++i) {
561+
if (i > 0) oss << ", ";
562+
oss << conflicting_regulators[i];
563+
}
564+
std::string ids = oss.str();
565+
throw ConflictingVoltageRegulatorURef{ids};
558566
}
559567
}
560568
}

0 commit comments

Comments
 (0)