Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-03-22 16:32:03


Dirk Griffioen wrote:

> I would love to use the boost::iostreams lib, so I created a filter
> (which, in this case, does encryption)
>
> but instead of passing it std::cout I would like to pass it some other
> stream, a stringstream for instance (or any kind of ostream/istream,
> depending on the direction).

> However, I was very surprised to find the following code taking 100%
> cpu and not returning. It probably means I did something wrong, but I
> can't seem to find it.

Here's a cleaned up example that reproduces the bug (when endl is replaces by
"\n"). It seems the filter is a red herring.

Jonathan

#include <iostream>
#include <sstream>
#include <boost/iostreams/filtering_stream.hpp>

int main()
{
    boost::iostreams::filtering_ostream out;
    std::ostringstream os;
    out.push(os);
    out << "test" << std::endl;
    //out << "test" << "\n";
    std::cout << os.str();
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk