add cpp version iterator pattern