A grueling test of templatization and maybe smart pointers