Boost logo

Boost Users :

Subject: [Boost-users] [iostreams] Why can't I use 'stream<file>' to write to a file?
From: Wim van der Meer (wpjvandermeer_at_[hidden])
Date: 2011-06-22 02:34:12


Hi,

I have started to use the Boost iostreams library in one of my projects. I
am using the latest Boost version, 1.46.1 with a 64-bit Linux OS on a x86-64
architecture.

When I compile and run the small program below, "HeavyArtillery2.txt" is
created, but "HeavyArtillery1.txt" is not, and I don't understand why. Am I
missing something obvious?

#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/file.hpp>

namespace io = boost::iostreams;

int main(int argc, char *argv[])
{
    io::stream<io::file> out1;
    out1.open("HeavyArtillery1.txt");
    out1 << "Reach at that Arrogance which needs thy harm,\n"
            "And beat it down before its sins grow worse.\n";
    out1.close();

    io::stream<io::file_sink> out2;
    out2.open("HeavyArtillery2.txt");
    out2 << "Reach at that Arrogance which needs thy harm,\n"
            "And beat it down before its sins grow worse.\n";
    out2.close();
}

-- 
Wim van der Meer


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net