Fixing const usage on a template function