Skip to content
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

format no longer working on c++20 and above #2893

Closed
farmerpiki opened this issue May 13, 2022 · 1 comment
Closed

format no longer working on c++20 and above #2893

farmerpiki opened this issue May 13, 2022 · 1 comment
Labels

Comments

@farmerpiki
Copy link

(https://godbolt.org/z/P8szrvdbE)

format no longer works with dynamic strings due to consteval with c++20 and c++2b

I suggest a version should be provided which is runtime evaluated, for use for example where the string is a template read from a file

@vitaut
Copy link
Contributor

vitaut commented May 13, 2022

You can pass a dynamic (runtime) string by passing it in fmt::runtime (https://godbolt.org/z/5n33h66fW):

  std::string dynamic = "Hello there!";
  fmt::format(fmt::runtime(dynamic));

Quoting the documentation (https://fmt.dev/latest/api.html):

To pass a runtime format string wrap it in fmt::runtime().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants