KMP searching algorithm in C++, with template generic programming