add cpp implementation for AVL, with template support