[cpp] add unique elements