Skip to content

Commit ee76668

Browse files
latlng: nested libfmt formatting
1 parent bea0835 commit ee76668

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

include/geo/latlng.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@ uint32_t tile_hash_32(latlng const&);
3838

3939
} // namespace geo
4040

41-
#if __has_include("fmt/ostream.h")
41+
#if __has_include("fmt/format.h")
4242

43-
#include "fmt/ostream.h"
43+
#include "fmt/format.h"
4444

4545
template <>
46-
struct fmt::formatter<geo::latlng> : ostream_formatter {};
46+
struct fmt::formatter<geo::latlng> : nested_formatter<double> {
47+
auto format(geo::latlng const& p, format_context& ctx) const {
48+
return write_padded(ctx, [&](auto out) {
49+
return format_to(out, "({}, {})", nested(p.lat_), nested(p.lng_));
50+
});
51+
}
52+
};
4753

4854
#endif

0 commit comments

Comments
 (0)