Just create and fill your own numpunct face:
struct no_separator : std::numpunct<char> { protected: virtual string_type do_grouping() const { return "\000"; }
If you need to create specific output for reading another application, you can also override virtual char_type numpunct::do_decimal_point() const; .
If you want to use a specific locale as a base, you can get faces from _byname :
template <class charT> struct no_separator : public std::numpunct_byname<charT> { explicit no_separator(const char* name, size_t refs=0) : std::numpunct_byname<charT>(name,refs) {} protected: virtual string_type do_grouping() const { return "\000"; } // groups of 0 (disable) }; int main() { cout.imbue( locale(std::locale(""), // use default locale // create no_separator facet based on german locale new no_separator<char>("German_germany")) ); cout << "i: " << int(123456) << " f: " << float(3.14) << "\n"; }
source share