Skip to content

Commit

Permalink
Update fmt Formatters for Compatibility with Versions below 11 (#3172)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnaf-tahmid-chowdhury authored Oct 18, 2024
1 parent c19b9b1 commit 82a6f9e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions include/openmc/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ struct formatter<std::array<T, 2>> {
}

template<typename FormatContext>
auto format(const std::array<T, 2>& arr, FormatContext& ctx) const
#if FMT_VERSION >= 110000 // Version 11.0.0 and above
auto format(const std::array<T, 2>& arr, FormatContext& ctx) const {
#else // For versions below 11.0.0
auto format(const std::array<T, 2>& arr, FormatContext& ctx)
{
#endif
return format_to(ctx.out(), "({}, {})", arr[0], arr[1]);
}
};
}
}; // namespace fmt

} // namespace fmt
10 changes: 7 additions & 3 deletions include/openmc/position.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,16 @@ namespace fmt {
template<>
struct formatter<openmc::Position> : formatter<std::string> {
template<typename FormatContext>
auto format(const openmc::Position& pos, FormatContext& ctx) const
#if FMT_VERSION >= 110000 // Version 11.0.0 and above
auto format(const openmc::Position& pos, FormatContext& ctx) const {
#else // For versions below 11.0.0
auto format(const openmc::Position& pos, FormatContext& ctx)
{
#endif
return formatter<std::string>::format(
fmt::format("({}, {}, {})", pos.x, pos.y, pos.z), ctx);
}
};
}
}; // namespace fmt

} // namespace fmt

Expand Down

0 comments on commit 82a6f9e

Please sign in to comment.