I want to use the fmt library to format floating point numbers.
I try to format a floating point number with decimal separator ',' and tried this without success:
#include <iostream>
#include <fmt/format.h>
#include <fmt/locale.h>
struct numpunct : std::numpunct<char> {
protected:
char do_decimal_point() const override
{
return ',';
}
};
int main(void) {
std::locale loc;
std::locale l(loc, new numpunct());
std::cout << fmt::format(l, "{0:f}", 1.234567);
}
Output is 1.234567
. I would like 1,234567
Update:
I browsed the source of the fmt library and think that the decimal separator is hard coded for floating point numbers and does not respect the current locale.
I just opened an issue in the fmt library