fork(3) download
  1. #include <iostream>
  2. #include <locale>
  3.  
  4. template <typename T>
  5. struct comma_separator : std::numpunct<T>
  6. {
  7. typename std::numpunct<T>::char_type do_decimal_point() const
  8. {
  9. return ',';
  10. }
  11. };
  12.  
  13. template <typename T>
  14. std::basic_ostream<T>& comma_sep(std::basic_ostream<T>& os)
  15. {
  16. os.imbue(std::locale(std::locale(""), new comma_separator<T>));
  17. return os;
  18. }
  19.  
  20. int main()
  21. {
  22. std::cout << comma_sep << 3.14; // 3,14
  23. }
Success #stdin #stdout 0s 4560KB
stdin
Standard input is empty
stdout
3,14