title: Loop condition works well with raw iterator but not with iterator dereferencing
body: <p>In the snippet below,
  <code>while(litr &lt; = ritr)</code> works well, but <code> while(*litr &lt; *ritr)</code> can not be met and goes out of range and crashes when try to search element which is not present in vector. <strong>I understand, loop will work with raw iterators but Why loop condition can not be met with iterator dereference</strong>?</p>
  <pre><code>bool binarySearch(std::vector&lt;int&gt; sorted_list, int item)
  {
      if(sorted_list.empty())
      {
          return false;
      }
      
      auto litr = sorted_list.begin();
      auto ritr = sorted_list.end()-1;
  
      while(litr &lt;= ritr)
      {
          int leftindex = std::distance(sorted_list.begin(), litr);
          int rightindex = std::distance(sorted_list.begin(), ritr);
  
          int mid = (leftindex + ((rightindex-leftindex)/2));
  
          if(sorted_list.at(mid) == item)
          {
              return true;
          }
  
          if(item &lt; sorted_list.at(mid))
          {
              ritr = sorted_list.begin() + mid-1;
          }
          else
          {
              litr = sorted_list.begin()+ mid+1;
  
          }
      }
  
      return false;
  }
  </code></pre>