title: Is it well-defined to compare with a value-initialized iterator?
body: <p>Does the following program invoke undefined behavior?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iterator&gt;
  
  int main(int argc, char* argv[])
  {
      for (auto it = std::istream_iterator&lt;std::string&gt;(std::cin);
           it != std::istream_iterator&lt;std::string&gt;();
           ++it)
      {
          std::cout &lt;&lt; *it &lt;&lt; " ";
      }
  
      return 0;
  }
  </code></pre>
  
  <p>This <a href="https://stackoverflow.com/questions/1190112/comparing-default-constructed-iterators-with-operator">4 year old question</a> says that they can't be compared:</p>
  
  <blockquote>
    <p>Iterators can also have singular values that are not associated with
    any container. [Example: After the declaration of an uninitialized
    pointer x (as with int* x;), x must always be assumed to have a
    singular value of a pointer. ] Results of most expressions are
    undefined for singular values; the only excep- tion is an assignment
    of a non-singular value to an iterator that holds a singular value.</p>
  </blockquote>
  
  <p>But another answer for says for the C++14 standard:</p>
  
  <blockquote>
    <p>However, value-initialized iterators may be compared and shall compare
    equal to other value-initialized iterators of the same type.</p>
  </blockquote>