[PATCH] Fix initialization of _M_grouping

Benjamin Kosnik bkoz@redhat.com
Tue Jan 29 10:39:00 GMT 2002


> Nathan, may I consider this comment of yours as a permission to commit?

Please hold on. I was gone yesterday afternoon and didn't see any of 
this. 

I'm trying to figure out if this is what Nathan is talking about:

#include <locale>
#include <sstream>

struct testpunct : std::numpunct<char> 
{
  //  char do_thousands_sep() const { return '0'; }
  char do_thousands_sep() const { return '\0'; }
  std::string do_grouping() const { return std::string("\004"); }
};

int main()
{
  // "1\00023\00045"
  // "1,0023,0045"
  const std::string str("1\00023\00045", 7);
  std::stringstream ss(str);

  const std::locale loc(std::locale::classic(), new testpunct); 
  ss.imbue(loc);

  long l;
  ss >> l;
  assert(l == 1023045);
  return 0;
}



More information about the Libstdc++ mailing list