From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-03-22 15:32:12
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).
Right, you're supposed to be able to do this.
> 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.
I've changed you're code a bit (see attached), since the code you posted doesn't
Here's the situation:
- The code works with GCC 3.4 (Cygwin), Intel 8.0 with Dinkumware, and VC7.1.
- If the line
out << speech << std::endl;
is replaced by
out << speech << "\n";
the code works with GCC 3.4, Intel 8.0 and VC7.1 in release mode, but hangs at
the end of the function test_encryption_filter() with VC7.1 in debug mode. (Note
when I say "works", it might not work as you expected, since the stream is never
flushed so the output is empty.)
I'm not sure why the program hangs in debug mode, but I'm hoping it will be
easier to track down than if it only failed in release mode ;-) It may be a
problem in how resources are cleaned up when a stream is closed, which has
proved to be the main source of bugs.
I'm not sure when I'll be able to work on it, but I'll let you know what I
begin 666 example.cpp
M8VAA<BH@<RP@<W1R96%M<VEZ92!N*0T*(" @(" @("![#0H@(" @(" @(" @
M("!W:&EL92 H;BTM(#X@,"D-"B @(" @(" @(" @(" @("!B;V]S=#HZ:6]S
M=')E86US.CIP=70H<VYK+"!T;W5P<&5R*"IS*RLI*3L-"B @(" @(" @?0T*
M(" @(&-O;G-T(&-H87(J('-P965C:" ]#0H-"B @(" @(" @(E1H97D@<V]R
M:&5Y("(-"@T*(" @(" @(" B=&AI;FL@=V4@=VEL;"!L970@=&AE;2!O8G1A
M:6X@;G5C=6QA<B!W96%P;VYS+B!4:&ES("(-"@T*(" @(" @(" B;6%L9F5A
M>2!A#0H@(" @+R\@=&5S=%]O=71P=71?9FEL=&5R+@T*#0H@(" @8F]O<W0Z
M:6YG<W1R96%M(&]S.PT*#0H@(" @;W5T+G!U<V_at_H;W,I.PT*#0H@(" @+R\@
M=70@/#P@<W!E96-H(#P\(")<;B([#0H-"B @(" O+R!7<FET92!S=')I;F=S
M=')E86T_at_8V]N=&5N=',@=&\@8V]U=#H-"B @(" -"B @("!S=&0Z.F-O=70@
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk