title: Is it safe to use std::prev(vector.begin()) or std::next(vector.begin(), -1) like some_container.rend() as reversed sentry?
body: <p>I wrote some code that takes iterators but have to do comparison in reversed order,</p>
  
  <pre><code>template&lt;class ConstBiIter&gt;
  bool func(ConstBiIter seq_begin, ConstBiIter seq_end)
  {
      ConstBiIter last = std::prev(seq_end);
      while (--last != std::prev(seq_begin)) // --&gt; I need to compare the beginning data
      {
          ......
      }
      return true;
  }
  </code></pre>
  
  <p>In VS2013, when running in Debug mode, <code>--last != std::prev(seq_begin)</code> will cause debugger assertion fail with the error message</p>
  
  <pre><code>Expression:string iterator + offset out of range.
  </code></pre>
  
  <p>but it is perfectly OK when running in Release mode and giving out correct result, because there's no boundary check in Released mode.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>Is it safe to use <code>std::prev(some_container.begin())</code> as sentry like <code>some_container.rend()</code>?</p></li>
  <li><p>How can I directly compare a <code>reverse_iterator</code> with an <code>iterator</code>?  If I write the code:
  <code>std::cout &lt;&lt; (std::prev(some_container.begin())==some_container.rend()) &lt;&lt; std::endl;</code> it won't compile, even if you <code>reinterpret_cast</code> them.</p></li>
  </ol>
  
  <p>I am curious if <code>prev(some_container.begin())</code> equals <code>some_container.rend()</code> physically?</p>