fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream> /// istringstream
  4.  
  5.  
  6. using namespace std;
  7.  
  8.  
  9. template<typename S>
  10. void StreamLocaleName(S& s,
  11. string m)
  12. {
  13. /// Get the stream's locale.
  14. locale loc = s.rdbuf()->getloc();
  15.  
  16. /// Display locale name.
  17. cout << m << "'s locale: "
  18. << loc.name() << endl;
  19. }
  20.  
  21.  
  22. int main()
  23. {
  24. string s {};
  25. istringstream iss {s};
  26.  
  27. /// Display the istringstream's initial locale name.
  28. StreamLocaleName(iss, "iss");
  29.  
  30. /// Set the istringstream's locale to POSIX
  31. locale posix {"POSIX"};
  32. iss.imbue(posix);
  33.  
  34. /// Display the istringstream's new locale name.
  35. StreamLocaleName(iss, "iss");
  36. }
Success #stdin #stdout 0s 4360KB
stdin
Standard input is empty
stdout
iss's locale: C
iss's locale: C