views:

187

answers:

2

Is it possible to do something like cout << "my string"; and have my string capitalized? from what i can tell there is no way to do it? i need to wrap it around a function

+4  A: 

Yes, you can extend std:streambuf See this example: http://www.java2s.com/Tutorial/Cpp/0240__File-Stream/Extendsstdstreambuftocreateoutputbuffer.htm

Pierre
Filtering streambufs are indeed the way to go. You can also have a look at James Kanze's articles on the subject, and on boost.io that provides a framework inspired by James' article, that help defining filters.
Luc Hermitte
A: 

Use the Boost string_algo library:

string myStr("my string");
to_upper(myStr);
cout << myStr;
MattyT