Skip to content

Commit e73050a

Browse files
authored
[wpimath] Templatize formatters (wpilibsuite#6535)
This is required for compatibility with libc++'s std::format.
1 parent 3e6c0d0 commit e73050a

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

wpimath/src/main/native/include/frc/fmt/Eigen.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ template <typename Derived, typename CharT>
1818
requires std::derived_from<Derived, Eigen::DenseBase<Derived>> ||
1919
std::derived_from<Derived, Eigen::SparseCompressedBase<Derived>>
2020
struct fmt::formatter<Derived, CharT> {
21-
constexpr auto parse(fmt::format_parse_context& ctx) {
21+
template <typename ParseContext>
22+
constexpr auto parse(ParseContext& ctx) {
2223
return m_underlying.parse(ctx);
2324
}
2425

25-
auto format(const Derived& mat, fmt::format_context& ctx) const {
26+
template <typename FmtContext>
27+
auto format(const Derived& mat, FmtContext& ctx) const {
2628
auto out = ctx.out();
2729

2830
for (int row = 0; row < mat.rows(); ++row) {

wpimath/src/main/native/include/units/formatter.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
template <typename Unit, typename CharT>
2121
struct fmt::formatter<Unit, CharT,
2222
std::enable_if_t<units::traits::is_unit_t_v<Unit>>> {
23-
constexpr auto parse(fmt::format_parse_context& ctx) {
23+
template <typename ParseContext>
24+
constexpr auto parse(ParseContext& ctx) {
2425
return m_underlying.parse(ctx);
2526
}
2627

@@ -30,7 +31,8 @@ struct fmt::formatter<Unit, CharT,
3031
* @param obj Unit instance.
3132
* @param ctx Format string context.
3233
*/
33-
auto format(const Unit& obj, fmt::format_context& ctx) const {
34+
template <typename FmtContext>
35+
auto format(const Unit& obj, FmtContext& ctx) const {
3436
using Units = typename Unit::unit_type;
3537
using BaseUnits =
3638
units::unit<std::ratio<1>,

0 commit comments

Comments
 (0)