Tying inheritance instead of templating.

Templating was requiring us to write lots of duplicate code
to handle each type we cared about, which seems cross-purposes.
I have migrated the code to use inheritance instead in hopes
of simplifying the task of adding new supported types.

I have made sure the example still works :)