$C^\infty $ approximations of convex, subharmonic, and plurisubharmonic functions