ofstream myXMLFile (destPath, std::ios_base::out | std::ios_base::app | std::ios_base::binary);
boost::iostreams::filtering_streambuf<boost::iostreams::output> filteringOStream;
filteringOStream.push(boost::iostreams::zlib_compressor());
filteringOStream.push(myXMLFile);
std::ostream myExportedXMLFilteringOStream(&filteringOStream);
Foo(myExportedXMLFilteringOStream);
TO A filtering_ostream:
ofstream myXMLFile (destPath, std::ios_base::out | std::ios_base::app | std::ios_base::binary);
boost::iostreams::filtering_ostream myExportedXMLFilteringOStream;
myExportedXMLFilteringOStream.push(boost::iostreams::zlib_compressor());
myExportedXMLFilteringOStream.push(myXMLFile);
Foo(myExportedXMLFilteringOStream);