title: Which iomanip manipulators are 'sticky'?
body: <p>I recently had a problem creating a <code>stringstream</code> due to the fact that I incorrectly assumed <code>std::setw()</code> would affect the stringstream for every insertion, until I changed it explicitly. However, it is always unset after the insertion.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>// With timestruct with value of 'Oct 7 9:04 AM'
  std::stringstream ss;
  ss.fill('0'); ss.setf(ios::right, ios::adjustfield);
  ss &lt;&lt; setw(2) &lt;&lt; timestruct.tm_mday;
  ss &lt;&lt; timestruct.tm_hour;
  ss &lt;&lt; timestruct.tm_min;
  std::string filingTime = ss.str(); // BAD: '0794'
  </code></pre>
  
  <p>So, I have a number of questions:</p>
  
  <ul>
  <li>Why is <code>setw()</code> this way? </li>
  <li>Are any other manipulators this way? </li>
  <li>Is there a difference in behavior between <code>std::ios_base::width()</code> and <code>std::setw()</code>? </li>
  <li>Finally is there an online reference that clearly documents this behavior? My vendor documentation (MS Visual Studio 2005) doesn't seem to clearly show this.</li>
  </ul>