title: Is the size_t data type safe to use for str.find()?
body: <p>I've been looking at code for the <code>find()</code> function for strings, and they store the result of that in a variable with data type size_t. However it is my understanding that size_t is an unsigned int, and if <code>find()</code> does not find the intended string, it returns -1. For example if I have</p>
  
  <pre><code>string s = "asdf";
  size_t i = s.find("g")
  cout &lt;&lt; i;
  </code></pre>
  
  <p>It gives me 4294967295. However if I replace size_t with the int data type, it gives me -1. The strange thing is when I make a comparison like </p>
  
  <pre><code>string s = "asdf";
  size_t i = s.find("g")
  if (i == -1) { do_something; }
  </code></pre>
  
  <p>it works whether i is size_t or int. So which do I use? int or size_t?</p>