Skip to content

Commit

Permalink
Fix build with fmt 11
Browse files Browse the repository at this point in the history
fmt 11 enforces that fmt::formatter<..>::format() should be const.
otherwise the tree does not build:

```
/usr/include/fmt/base.h:1392:29: error: passing ‘const fmt::v11::formatter<std::optional<mtx::http::ClientError> >’ as ‘this’ argument discards qualifiers [-fpermissive]
 1392 |     ctx.advance_to(cf.format(*static_cast<qualified_type*>(arg), ctx));
      |                    ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

so let's mark the `format()` with `const` specifier.

Signed-off-by: Kefu Chai <[email protected]>
  • Loading branch information
tchaikov committed Jul 15, 2024
1 parent 018e208 commit 4a4726c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/mtxclient/http/errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct fmt::formatter<mtx::http::ClientError>
// Formats the point p using the parsed format specification (presentation)
// stored in this formatter.
template<typename FormatContext>
auto format(const mtx::http::ClientError &e, FormatContext &ctx) -> decltype(ctx.out())
auto format(const mtx::http::ClientError &e, FormatContext &ctx) const -> decltype(ctx.out())
{
// ctx.out() is an output iterator to write to.
bool prepend_comma = false;
Expand Down Expand Up @@ -132,7 +132,7 @@ struct fmt::formatter<std::optional<mtx::http::ClientError>> : formatter<mtx::ht
{
// parse is inherited from formatter<string_view>.
template<typename FormatContext>
auto format(std::optional<mtx::http::ClientError> c, FormatContext &ctx)
auto format(std::optional<mtx::http::ClientError> c, FormatContext &ctx) const
{
if (!c)
return fmt::format_to(ctx.out(), "(no error)");
Expand Down

0 comments on commit 4a4726c

Please sign in to comment.