title: Performance of size_t in C++
body: <p>I translated the code <a href="https://stackoverflow.com/questions/6146182/how-to-optimize-for-comprehensions-and-loops-in-scala">here</a> into C++ as follows</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int t = 20;
  
  bool is_evenly_divisible(const int a, const int b) {
      for (int i=2; i&lt;=b; ++i) { // Line 1
          if (a%i != 0)
              return false;
      }
      return true;
  }
  
  void run() {
      int i = 10;
      while (!is_evenly_divisible(i, t)) {
          i += 2;
      }
      cout &lt;&lt; i &lt;&lt; endl;
  }
  
  int main(int argc, char** argv) {
      run();
      return 0;
  }
  </code></pre>
  
  <p>With the -O3 flag on compiler g++ 4.8.1 on Mac OSX 10.8.4, I get time 0.568s user time.</p>
  
  <p>Now if I change the counter i in Line 1 in function is_evenly_divisible to size_t, the time suddenly jumps to 1.588s.
  This persists even if I change all of the variables to size_t, the time increases to 1.646s</p>
  
  <p>What's happening? Shouldn't size_t increase performance rather than decreasing it as it's a more specific type than int?</p>