title: C++ When are characters widened in output stream operator<<()?
body: <p>It seems to me, that there is an inconsistency in the C++ standard, specifically in §30.7.5.2.4 of the C++17 draft (N4659), about when characters are widened in formatted output operations on output streams (<code>operator&lt;&lt;()</code>). Exactly the same inconsistency seems to be reflected in <a href="http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt2" rel="noreferrer">en.cppreference.com</a>.</p>
  
  <p>First, assume the following declarations:</p>
  
  <pre><code>std::ostream out;
  std::wostream wout;
  char ch;
  wchar_t wch;
  const char* str;
  const wchar_t* wstr;
  </code></pre>
  
  <p>It is then stated that</p>
  
  <ol>
  <li><code>out &lt;&lt; ch</code> <strong>does not</strong> perform character widening,</li>
  <li><code>out &lt;&lt; str</code> performs character widening,</li>
  <li><code>wout &lt;&lt; ch</code> performs character widening,</li>
  <li><code>wout &lt;&lt; str</code> performs character widening,</li>
  <li><code>wout &lt;&lt; wch</code> <strong>does not</strong> perform character widening,</li>
  <li><code>wout &lt;&lt; wstr</code> performs character widening.</li>
  </ol>
  
  <p>The first and most obvious inconsistency is that (6) cannot be true, as there is no <code>widen()</code> function taking a <code>wchar_t</code> argument, only one that takes a <code>char</code> argument.</p>
  
  <p>The second (seeming) inconsistency is between (1) and (2). It seems strange to me that <code>out &lt;&lt; "x"</code> should widen <code>'x'</code>, while <code>out &lt;&lt; 'x'</code> should not.</p>
  
  <p>Am I misinterpreting the standard text, or is there something wrong there? If the latter is true, do you know what the intended behavior is?</p>
  
  <p>EDIT: Apparently, this inconsistency (if I am right), has been present in the standard since at least C++03 (§27.6.2.5.4). The text changes a bit through the intermediate standards, but the inconsistency, as I explain it above, remains.</p>