title: STL objects use C Runtime Library locale for floating point conversion, when using _ENABLE_PER_THREAD_LOCALE?
body: <p>The C Runtime locale is set by <code>setlocale</code>.
  The Standard C++ Library (STL) locale is set by the <code>std::locale</code> class and can be set on individual STL objects like std::istringstream etc.</p>
  
  <p>The function <code>_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)</code> allows setting the C Runtime locale on a per thread basis.</p>
  
  <p>Unfortunately it seems that STL objects in threads where <code>_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)</code> is enabled is using the C Runtime locale. Or at least using the decimal point of the C Runtime locale.</p>
  
  <p>In threads without <code>_ENABLE_PER_THREAD_LOCALE</code> there are no problems.</p>
  
  <p>Something similar was asked by Paavo in 2008, but with no answers: <a href="https://stackoverflow.com/questions/276030">_configthreadlocale and localeconv</a></p>
  
  <p>The following code shows the problem:</p>
  
  <pre><code>//Enable per thread locale in current thread  
  _configthreadlocale(_ENABLE_PER_THREAD_LOCALE)  
  
  //Create istringstream object  
  std::istringstream LibraryStream;  
  //Create double object  
  double Value = 0;  
  //Create std::locale object with "C" locale ("." as decimal point)  
  std::locale StreamLoc("C");  
  //Set C Runtime locale to danish ("," as decimal point)  
  setlocale(LC_ALL, "danish");  
  
  //Set the "C" locale on the istringstream object  
  LibraryStream.imbue(StreamLoc);  
  //Get the locale of the istringstream object for test (returns "C" as expected)  
  std::locale NewStreamLoc = LibraryStream.getloc();  
  
  //Set floating point string with "C" locale decimal point in istringstream object  
  LibraryStream.str("60.258351");  
  //Convert the string to double  
  LibraryStream &gt;&gt; Value;  
  
  //Now the expected value of "Value" is 60.258351, but it is 60.000  
  //when debugging the conversion, I can see that "," is used as decimal point  
  </code></pre>
  
  <p>Have anyone experienced this before? Am I doing something wrong? Are there any suggestions for solutions?</p>
  
  <p>Thanks in advance
  /TEB</p>