Templated heaps