title: Behavior when dereferencing the .end() of a vector of strings
body: <p>I'm wondering if it's "safe" to set a <code>string</code> equal to whatever is returned by dereferencing the off-the-end <code>iterator</code> of a <code>vector</code> of <code>string</code>s. When I run the program </p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;string&gt;
  
  int main()
  {
  
      std::vector&lt;std::string&gt; myVec;
      std::cout &lt;&lt; *myVec.end();
      return 0;
  }
  </code></pre>
  
  <p>I get the following error. </p>
  
  <pre><code>/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../include/c++/4.1.2/debug/safe_iterator.h:181:
      error: attempt to dereference a past-the-end iterator.
  
  Objects involved in the operation:
  iterator "this" @ 0x0xffdb6088 {
  type = N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIPSsN10__gnu_norm6vectorISsSaISsEEEEEN15__gnu_debug_def6vectorISsS6_EEEE (mutable iterator);
    state = past-the-end;
    references sequence with type `N15__gnu_debug_def6vectorISsSaISsEEE' @ 0x0xffdb6088
  }
  
  Disallowed system call: SYS_kill
  </code></pre>
  
  <p>You can view it at <a href="http://codepad.org/fJA2yM30" rel="noreferrer">http://codepad.org/fJA2yM30</a></p>
  
  <p>The reason I'm wondering about all this is because I have a snippet in my code that is like</p>
  
  <pre><code>std::vector&lt;const std::string&gt;::iterator iter(substrings.begin()), offend(substrings.end());
  while (true)
  {
      this_string = *iter;
      if (_programParams.count(this_string) &gt; 0)
      {
          this_string = *++iter;
  </code></pre>
  
  <p>and I want to make sure something weird doesn't happen if <code>++iter</code> is equal to <code>offend</code>.</p>