Can i output some text to a file using solely boost libraries?
The code i have (official documentation):
#include <ostream>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/stream.hpp>
namespace io = boost::iostreams;
int main()
{
io::stream_buffer<io::file_sink> buf("log.txt");
std::ostream out(&buf);
// out writes to log.txt
out << "abc";
}
Is there another way? (i dont want to use std streams). Thanks in advance.
io::stream_bufferis derived fromstd::basic_streambuf, so you can use nativebasic_streambufpublic methods, or you can useboost::filesystemstreams, but all of such classes are derived fromstd::classes.http://www.boost.org/doc/libs/1_50_0/libs/filesystem/doc/reference.html#File-streams