Optimizing with C++11 templates