//Purpose: // Explore differences in ways iostreams filtering is done // with different device types. //Acknowledgements: // Original code from post: /* From: Ken Appleby Newsgroups: gmane.comp.lib.boost.user Subject: Re: [iostreams] How can I use the Stream Insertion operator (<<) with a filtering_streambuf? Date: Fri, 26 Jul 2013 18:06:47 +0100 Lines: 94 */ //ChangeLog: // 2013-07-29.0847 // Converted to use: // filtering_estream // instead of: // filtering_streambuf // after reading post: /* From: Stephen Greenfield Newsgroups: gmane.comp.lib.boost.user Subject: Re: [iostreams] How can I use the Stream Insertion operator (<<) with a filtering_streambuf? Date: Mon, 29 Jul 2013 04:28:04 +0000 Lines: 167 */ //========================== #include //#define USE_STRINGSTRM //use stringstream instead of fstream. #ifdef USE_STRINGSTRM #include #else #include #endif #include #include #include int main() { try { #ifdef USE_STRINGSTRM std::string strmValue(""); #else char const*filePath="hello.gz"; #endif { #ifdef USE_STRINGSTRM std::ostringstream myOstrm( strmValue); #else std::ofstream myOstrm( filePath ); #endif boost::iostreams::filtering_ostream out; out.push(boost::iostreams::gzip_compressor()); out.push( myOstrm ); out << "text to be in the file..."; #ifdef USE_STRINGSTRM out.flush(); strmValue=myOstrm.str(); #endif } #ifdef USE_STRINGSTRM std::cout<<"strmValue="<