cpp: do not lock key on iteration