does anyone know if this function can be ported to c++?