title: std::map iterator initialization by zero in C++
body: <p>I need to initialize an interator by zero value. I tried following code</p>
  
  <pre><code>#include &lt;map&gt;
  std::map&lt;int, int&gt;::iterator foo() {
      std::map&lt;int, int&gt;::iterator ret;
      ret = std::map&lt;int, int&gt;::iterator(0);
      return ret;
  }
  </code></pre>
  
  <p>It successfully compiled by gcc and intel C++ compilers on Linux. Also, this compiled well in minGW on Windows. The code provided with -O2 is</p>
  
  <pre><code>xorl eax, eax
  ret
  </code></pre>
  
  <p>The issue is compilation under VisualStudio. The error is:
  error C2440: '' : cannot convert from 'int' to 'std::_Tree_iterator>>> No constructor could take the source type, or constructor overload resolution was ambiguous.</p>
  
  <p>Could you please give me an idea how to cast zero or rephrase initialization of iterator?</p>
  
  <p>Thank you</p>
  
  <p>PS</p>
  
  <p>main idea is getting NULL at the end of the "list" </p>
  
  <blockquote>
    <p>(it = a.begin(); it != a.end(); it = it->next)</p>
  </blockquote>
  
  <p>that based on map::iterators from diffrent map objects. </p>
  
  <pre><code>a::end() {
      return std::map&lt;K, V&gt;::iterator(0)
  }
  </code></pre>