title: How does one author a portable container which behaves well with MSVC++'s checked iterators feature?
body: <p>I'm defining a new type of container for various reasons. I would like to be mostly similar to <code>std::vector</code>'s interface; and it just so happens that for enumeration purposes I can leave <code>wchar_t *</code> and <code>wchar_t const*</code> as my <code>iterator</code> type and <code>const_iterator</code> type, respectively. (This container is a "view" on top of some other, larger, data structure that just happens to have a vector-compatible interface)</p>
  
  <p>However, if I do this, users using MSVC++ are going to get crazy numbers of warnings from algorithms like <code>std::copy</code>, unless they define <code>_SCL_SECURE_NO_WARNINGS</code>. This is a good thing -- <a href="http://msdn.microsoft.com/en-us/library/aa985965.aspx" rel="noreferrer">MSVC++'s checked iterators feature</a> protects users from all kinds of bugs in debug mode. I would like to be compatible with this feature by implementing such checking features where required. This leaves a couple of questions:</p>
  
  <ol>
  <li>VC's <code>stdext::checked_iterator</code> class accepts a container in its constructor. Is that container required to be one of the built in STL container types?</li>
  <li>How can I disable checked iterators when <a href="http://msdn.microsoft.com/en-us/library/hh697468.aspx" rel="noreferrer"><code>_ITERATOR_DEBUG_LEVEL</code></a> is <code>0</code>?</li>
  <li>How can I do this in such a way that the container is portable to other compilers which don't have checked iterators? (I would like to avoid implementing the whole thing twice if possible)</li>
  </ol>
  
  <p>Boost solutions are okay.</p>