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
Hi; I'm hitting an issue where user-defined types which overload operator<< are causing seemingly wrongly formatted output if using format_to_n. fmt::format seems to work okay.
Here's an example; I tried against fmtlib 5.1.0 (seems to behave similarly for older versions). I'm building with Visual Studio 2015 on windows, but I think I might be seeing similar behaviour with Xcode (I can confirm if needed).
#include "stdafx.h"
#define FMT_HEADER_ONLY 1
#include <fmt/format.h>
#include <fmt/ostream.h>
class Test
{
public:
friend std::ostream& operator<<(std::ostream& strm, const Test& cpstr)
{
return strm << "555";
}
};
int main()
{
Test a;
char buf[256];
fmt::format_to_n_result<char*> res = fmt::format_to_n(buf, 256, "Test {} end", a);
// buf contains Test end
std::string s = fmt::format("Test {} end", a);
s = s;
// s contains Test 555 end
}
If I switch to use the other style (struct formatter per docs), things start working. But that's not ideal for me since I already have a bunch of classes with stream operators overridden already in various bits of my project.
The text was updated successfully, but these errors were encountered:
Hi; I'm hitting an issue where user-defined types which overload operator<< are causing seemingly wrongly formatted output if using format_to_n. fmt::format seems to work okay.
Here's an example; I tried against fmtlib 5.1.0 (seems to behave similarly for older versions). I'm building with Visual Studio 2015 on windows, but I think I might be seeing similar behaviour with Xcode (I can confirm if needed).
If I switch to use the other style (struct formatter per docs), things start working. But that's not ideal for me since I already have a bunch of classes with stream operators overridden already in various bits of my project.
The text was updated successfully, but these errors were encountered: