Example code: https://godbolt.org/z/erD-_a
In v6 fmt::format_to_n() seems to work with fmt::compile()-d format string.
In v7 though, just fmt::format_to() is working with FMT_COMPILE().
A workaround for now is to use fmt's truncating iterator with fmt::format_to:
static const auto formatter = FMT_COMPILE("{}");
std::array<char, 512> s2{0};
// These two lines should be equivalent
// auto it = fmt::format_to_n(s0.data(), 512, formatter, 42).out; // fails at compile time
auto it = fmt::format_to(fmt::detail::truncating_iterator<char*>(s2.data(), s2.size()), formatter, 42).base();
std::cout << s2.data() << std::endl;
A PR to add format_to_n overload that accepts FMT_COMPILE is welcome.
Implemented in #1767 and #1869. Thanks @Kurkin and @alexezeder.