add some C++-safe casts