Custom manipulator for C++ iostream
问题 I\'d like to implement a custom manipulator for ostream to do some manipulation on the next item being inserted into the stream. For example, let\'s say I have a custom manipulator quote : std::ostringstream os; std::string name(\"Joe\"); os << \"SELECT * FROM customers WHERE name = \" << quote << name; The manipulator quote will quote name to produce: SELECT * FROM customers WHERE name = \'Joe\' How do I go about accomplishing that? Thanks. 回答1: It's particularly difficult to add a