I'm trying to use a thousands separator in some serialization code and I've opted for using a custom locale for my ofstreams. A minimal example using cout (the example uses cout instead of ofstream because I have to show you something onscreen) would be the following:
#include <iostream>
#include <limits>
#include <locale>
class split_every_three : public std::numpunct<char>
{
protected:
    virtual char do_thousands_sep() const { return '\''; }
    virtual std::string do_grouping() const { return "\03"; }
};
int main()
{
    std::cout.imbue( std::locale( std::locale::classic(), new split_every_three ) );
    
    std::cout << 1234589 << std::endl;
    std::cout << 12342.424134 << std::endl;
    return 0;
}
which Outputs:
1'234'589
12'342.4
The problem is the second line, i.e. floating point numbers won't print all decimal digits. How can I fix it? (and what have I done to break this?)
 
    