The semantics between those two tests are identical, where one is using regular functions and the other function templates. The tests iterate through 30 million random vectors (but identical in both tests).

The size of the grid is a compile time constant, and the compiler has the chance to optimize the regular method the same way as the function template. I haven’t tested this on Linux with gcc/g++, so it might be quirk with the VS2010 C++ compiler.

In the real world there is no difference, given the following time per invocation:

No one will notice the difference between 7 nanoseconds or 17 nanoseconds.