How to do this and that in C++ using templates.