-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LWG 3636 #3447
Labels
Comments
#include <fmt/format.h>
#include <format>
struct A {};
template<>
struct fmt::formatter<A> {
auto format(A, auto& ctx) /* const */ -> decltype(ctx.out());
constexpr auto parse(auto& ctx) { return ctx.begin(); }
};
template<>
struct std::formatter<A> : fmt::formatter<A> {};
int main() {
(void) fmt::format("{}", A()); // 1
(void) std::format("{}", A()); // 2
} compiles (1) but fails to compile (2). Uncommenting the |
maybe just add the |
Done in d707292. |
facebook-github-bot
pushed a commit
to facebookincubator/fizz
that referenced
this issue
Aug 8, 2024
Summary: starting from [fmt11.0.0](fmtlib/fmt#3447), fmt requires formatter::format to be const. > Started enforcing that formatter::format is const for compatibility with std::format Pull Request resolved: #144 Reviewed By: NickR23 Differential Revision: D60912017 Pulled By: mingtaoy fbshipit-source-id: 49e367c509a84523455220d791402ca4669942bd
facebook-github-bot
pushed a commit
to facebook/hhvm
that referenced
this issue
Sep 11, 2024
Summary: starting from [fmt11.0.0](fmtlib/fmt#3447), fmt requires formatter::format to be const. > Started enforcing that formatter::format is const for compatibility with std::format X-link: facebookincubator/fizz#144 Reviewed By: NickR23 Differential Revision: D60912017 Pulled By: mingtaoy fbshipit-source-id: 49e367c509a84523455220d791402ca4669942bd
le-migou
added a commit
to calculisto/units
that referenced
this issue
Sep 30, 2024
fmtlib/fmt#3447 Signed-off-by: Emmanuel LE TRONG <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Per https://cplusplus.github.io/LWG/issue3636, formatters should have
format() const
. Failure to enforce this impedes compatibility with standard formatting i.e. once we've written formatters for fmt, we need to go and addconst
onformat()
to make them compatible with std::format.Please consider enforcing that
formatter<T>::format()
specialization member functions can be calledconst
. Perhaps this could be done with deprecation initially.The text was updated successfully, but these errors were encountered: