cpp: add bitfield implementation