fmtlib / fmt

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

upgrading from 7.1.3 gives a compile error for user defined types even with an ostream operator defined #3425

Closed rglarix closed 1 year ago

rglarix commented 1 year ago

Hi, we have been using fmtlib for many years, both as a replacement for sprintf, and more recently to (slowly) migrate to format. For several types we have defined ostream operator << methods, using it for both sprintf and format. It's quite a big project and moves rather slowly, we are now at 7.1.3 and would like to upgrade to the latest release. But we realized that operator << no longer works for sprintf. For us this is a big regression, because we have over 20,000 sprintfs, even though not all use a custom formatter. Is there any way to reintroduce the formatter from ostream << to sprintf as well?

rglarix commented 1 year ago

oops, fmt/ostream.h somehow was forgotten. sorry for the noise

rglarix commented 1 year ago

sorry, but it seems that from 9.0.0 onward fmt::sprintf cannot format from operator << anymore for example https://godbolt.org/z/v7Pqd5nWa With 8.1.1 works, but not with 9.x

vitaut commented 1 year ago

That's expected. ostream interface is only compatible with format-like functions. It only happened to partially work in older versions with printf by accident.