-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Since fmtlib 8 the following overload provided in format.h is deprecated:
template <typename... T, size_t SIZE, typename Allocator>
FMT_DEPRECATED auto format_to(basic_memory_buffer<char, SIZE, Allocator>& buf,
format_string<T...> fmt, T&&... args)
-> appender;
It would be appreciated, if this deprecation could be either rethought or at least the code docs (e.g. of class template basic_memory_buffer) that still use this usage as example should be adjusted and a recommended replacement should be mentioned.
I tested as replacement for
fmt::memory_buffer buffer;
fmt::format_to(buffer, "{0} {1}", "Hello", "world");
the alternative
fmt::memory_buffer buffer;
fmt::format_to(std::back_inserter(buffer), "{0} {1}", "Hello", "world");
which works but leads to performance losses (measured via benchmark) of about 5% in release (and ~10% in debug) builds.
We use the now deprecated overload a lot in low-level functions where we still want to get compile-time validation (So vformat is not an alternative) and would like to keep the previous performance characteristics.
Assuming that the idea behind the deprecation is to prevent problems compared to std::format_to, would it be possible to provide a differently named overload or within an additionally nested namespace? Note that providing such an overload by user-code is not only an unnecessary burden, but also not actually safe to do, because the deprecated overload delegates to detail::vformat_to, which is non-public API.