implement template cpp model