You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example for defining a custom formatter via specializing the formatterstruct in https://fmt.dev/latest/api.html#formatting-user-defined-types fails to compile when the definition of the format function is in a different compilation unit than its usage.
Using color.h and color.cc as in the API doc and a simple main.cc:
#include "color.h"
int main() { fmt::print("{}\n", color::red); }
gives the error (gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) ):
/workspaces/frawen/temp/fmt-10.2.1/include/fmt/core.h:1328:28: error: use of ‘auto fmt::v10::formatter<color>::format(color, fmt::v10::format_context&) const’ before deduction of ‘auto’
After amending the signature of format to
auto format(color c, format_context &ctx) const -> format_context::iterator
in both color.h and color.cc, the code works as expected.
(No godbolt because I couldn't get its multifile mode to work.)
The text was updated successfully, but these errors were encountered:
The example for defining a custom formatter via specializing the
formatter
struct in https://fmt.dev/latest/api.html#formatting-user-defined-types fails to compile when the definition of theformat
function is in a different compilation unit than its usage.Using color.h and color.cc as in the API doc and a simple main.cc:
gives the error (gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) ):
After amending the signature of
format
toin both color.h and color.cc, the code works as expected.
(No godbolt because I couldn't get its multifile mode to work.)
The text was updated successfully, but these errors were encountered: