some cpp function templates