title: Is it safe to use negative integers with size_t?
body: <p>I just saw some C++ code like this. It was using a condition to decide whether to walk forward or backward through a <code>std::vector</code>.  The compiler doesn't complain, but I thought <code>size_t</code> was unsigned. Is this dangerous?</p>
  
  <pre><code>vector&lt;int&gt; v { 1,2,3,4,5 };    
  bool rev = true;
  
  size_t start, end, di;
  if (rev) {
      start = v.size()-1;
      end = -1;
      di = -1;
  }
  else {
      start = 0;
      end = v.size();
      di = 1;
  }
  
  for (auto i=start; i!=end; i+=di) {
      cout &lt;&lt; v[i] &lt;&lt; endl;
  }
  </code></pre>