This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix initialization of _M_grouping



> 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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]