fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.83k stars 2.42k forks source link

make format_int constexpr? #4031

Closed dixlorenz closed 1 week ago

dixlorenz commented 1 week ago

I was looking at format_int and it seems to me that all the functions that it calls are constexpr in c++20. I tried simply prefixing everything in format_int with constexpr, now this compiles:

static_assert(fmt::format_int(DLCL::to_integral(42)).str() == "42");

Is there a reason format_int is not constexpr?

vitaut commented 1 week ago

The only reason is that nobody was interested in making it constexpr yet. A PR would be welcome.

dixlorenz commented 1 week ago

PR is up, I tried to match the code style as closely as I could see.