title: Program crash on printing wstringstream
body: <p>The code below is inside of a DLL that I'm using to hook <code>CreateWindowExA()</code> and other functions.</p>
  <p>The current hooked app is crashing when I use <code>std::wstringstream</code> to print the values of the variables to <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/debugview" rel="nofollow noreferrer">DebugView</a>. I confirmed that when I comment the <code>std::wstringstream</code> it doesn't crash.</p>
  <p>What other option can I use to print their values that I don't need to specify each variable type, as you do on <code>wsprintf()</code>?</p>
  <pre><code>HWND __stdcall CreateWindowExA_Hook(
      DWORD     dwExStyle,
      LPCSTR    lpClassName,
      LPCSTR    lpWindowName,
      DWORD     dwStyle,
      int       X,
      int       Y,
      int       nWidth,
      int       nHeight,
      HWND      hWndParent,
      HMENU     hMenu,
      HINSTANCE hInstance,
      LPVOID    lpParam
  )
  {
      std::wstringstream text;
      text &lt;&lt; L&quot;dwExStyle: &quot; &lt;&lt; dwExStyle &lt;&lt; L&quot; lpClassName: &quot; &lt;&lt; lpClassName &lt;&lt; L&quot; lpWindowName: &quot; &lt;&lt; lpWindowName
      &lt;&lt; L&quot; dwStyle: &quot; &lt;&lt; dwStyle &lt;&lt; L&quot; X: &quot; &lt;&lt; X &lt;&lt; L&quot; Y: &quot; &lt;&lt; Y &lt;&lt; L&quot; nWidth: &quot; &lt;&lt; nWidth &lt;&lt; L&quot; nHeight: &quot; &lt;&lt; nHeight
      &lt;&lt; L&quot; hWndParent: &quot; &lt;&lt; hWndParent &lt;&lt; L&quot; hMenu&quot; &lt;&lt; hMenu &lt;&lt; L&quot; hInstance: &quot; &lt;&lt; hInstance &lt;&lt; L&quot; lpParam: &quot; &lt;&lt; lpParam;
  
      OutputDebugString(L&quot;CreateWindowExA:&quot;);
      OutputDebugString(text.str().c_str());
      OutputDebugString(L&quot; &quot;);
  
      return CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
  }
  </code></pre>
  <p>I wonder if there's any 'better' way than doing this:</p>
  <pre><code>std::wstringstream ss;
  ( dwExStyle ? ss &lt;&lt; L&quot;dwExStyle: &quot; &lt;&lt; dwExStyle : ss &lt;&lt; 0 );
  ( lpClassName ? ss &lt;&lt; L&quot; lpClassName: &quot; &lt;&lt; lpClassName : ss &lt;&lt; 0 );
  ( lpWindowName ? ss &lt;&lt; L&quot; lpWindowName: &quot; &lt;&lt; lpWindowName : ss &lt;&lt; 0 );
  ( dwStyle ? ss &lt;&lt; L&quot; dwStyle: &quot; &lt;&lt; dwStyle : ss &lt;&lt; 0 );
  ....
  
  OutputDebugString(L&quot;CreateWindowExA:&quot;);
  OutputDebugString(text.str().c_str());
  OutputDebugString(L&quot; &quot;);
  </code></pre>