Add template implementation for swig.