Inlined template copy function