[cpp] record function types for return casting