This does not works. Please fix it!
#include <iostream> #include <streambuf> #include <locale> #include <cstdio> template<class charT, class traits = std::char_traits<charT> > class basic_myoutbuf : public std::basic_streambuf<charT, traits> { protected: virtual typename traits::int_type overflow( typename traits::int_type c) { if ( ! traits::eq_int_type(c, traits::eof()) ) { c = std::toupper(c,getloc()); if ( putchar(c) == EOF ) return traits::eof(); } return c; } }; typedef basic_myoutbuf<char> myoutbuf; int main() { myoutbuf ob; std::cout.rdbuf(&ob); std::cout << "Hello world" << std::endl; return 0; }