title: num_get facet and stringstream conversion to boolean - fails with initialised boolean?
body: <p>I have inherited a template to convert a string to a numerical value, and want to apply it to  convert to <em>boolean</em>.  I am not very experienced with the stringstream and locale classes.  I do seem to be getting some odd behaviour, and I am wondering if someone could please explain it to me?</p>
  
  <pre><code>template&lt;typename T&gt; T convertFromString( const string&amp; str ) const {
  
  std::stringstream SStream( str );  
  T num = 0; 
  SStream &gt;&gt; num;
  
  return num;  
  }  
  </code></pre>
  
  <p>This works fine until I try the boolean conversion</p>
  
  <pre><code>string str1("1");
  int val1 = convertFromString&lt;int&gt;(str1); // ok
  string str2("true");
  bool val2 = convertFromString&lt;bool&gt;(str2); // val2 is _false_
  </code></pre>
  
  <p>I spent some time tracking down the problem.  I have confirmed that the locale's truename() returns "true".  </p>
  
  <p>The problem seems to be with the initialisation of the variable <em>num</em>.  I can change the template to this and it works:</p>
  
  <pre><code>template&lt;typename T&gt; T convertFromString( const string&amp; str ) const {
  
  std::stringstream SStream( str );  
  T num;  // &lt;----------------------- Changed here
  SStream &gt;&gt; num;
  
  return num;  
  }  
  string str2("true");
  bool val2 = convertFromString&lt;bool&gt;(str2); // val2 is _true_
  </code></pre>
  
  <p>Why does it work?  I accept that initialising a bool with '0' is wrong, but why would this cause the <code>SStream&gt;&gt;num</code>conversion to fail?</p>