some cpp utility code