The error that @trevnorris reported is probably caused by the value of TypeName. Is there a reason for this function to be a template?