C++ template code