How to format my own objects when using STL streams?
问题 I want to output my own object to a STL stream but with customized formatting. I came up with something like this but since I never used locale and imbue before I have no idea if this makes sense and how to implement MyFacet and operator<<. So my questions are: does this make sense and how to implement MyFacet and operator<< ? The following is a simplified example which shows you what I want to do. struct MyObject { int i; std::string s; }; std::ostream &operator<<(std::ostream &os, const