power-grid-model
power-grid-model copied to clipboard
[FEATURE] More readable exception types
Describe the feature request
Since C++20
, the <format>
STL functionality was introduced to improve string formatting:
- more readable
- less use of
std::to_string
(only when strictly necessary) - no unnecessary copying between stack and heap
This issue is about replacing the current PowerGridError
and derived exceptions' constructor implementations with more readable patterns using formatted strings.
- For static format patterns,
std::format
can be used - For format patterns that are not compile-time known,
std::formatv
needs to be used
The documentation on either is relatively clear, so it should not be a hard ticket to pick up.
It is possible that MacOS needs an additional feature flag before we can use this feature: https://github.com/PowerGridModel/power-grid-model/actions/runs/8570641564/job/23489029489
Note that according to https://en.cppreference.com/w/cpp/compiler_support/20 , the XCode version we use in CI for MacOS (15.2) should support it, so this result was unexpected. See also https://github.com/PowerGridModel/power-grid-model/actions/runs/8570641564/job/23489028931#step:5:36