Add IO restrictions in `to_s(io)` for std classes