I tried to format a simple string that will be displayed in the console
long long duration = end - start;
double ms = static_cast<double>(duration) * 0.001;
std::string resoult = fmt::format("{} => Duration: {} micro, {} ms", m_Info.c_str(), duration, ms);
AE_TRACE(resoult);
where m_Info is std::string, duration is long long and ms is double.
The resoult looks like this:
-9891888000000.0 => Duration: 49172 micro, 412316861 ms
The std::string was displayed as random numbers and ms was supposed to be 49,172.
I tried
"{:s} => Duration: {:d} micro, {:f} ms"
but that resoulted in fmt::format_errror
. I used the same library in other file in the same project and didn't get such errors.
EDIT
I used some other fmt functions in the same part of code
long long duration = end - start;
double ms = duration * 0.001;
std::string test = "test";
fmt::memory_buffer temp;
fmt::format_to(temp, "{} {} {}", test, duration, ms);
AE_TRACE(fmt::format("{} {} {}", test, duration, ms));
AE_TRACE(temp.data());
AE_TRACE("{} {} {}"_format(test, duration, ms));
AE_TRACE(test);
In all of them std::string
and double
were displayed as some random numbers.
The last function printed the unformatted std::string
correctly, same happened when I tried it with long long
and double
.