A function to handle multiple datatypes

The reason? The compiler can optimize better with templates, in all likelihood. With pointers it can't assume anything.