template: added support to set template variable as arbitrary pointer

this makes it possible to implement iterators in template helpers.