[cpp] add swap case