Boost logo

Boost :

Subject: Re: [boost] Standard stream from C fopen()
From: Eric MALENFANT (Eric.Malenfant_at_[hidden])
Date: 2010-11-12 17:34:14

De : Claude
> So these lines are right?
> stream_buffer<file_descriptor_source> fpstream (fileno(fd));
> std::istream in (&fpstream);
> I making a stream_buffer from with a file_descriptor_source as template
> parameter...

Almost. You should create the file_descriptor_source to pass it to the stream_buffer's constructor:

  stream_buffer<file_descriptor_source> fpstream(file_descriptor_source(fileno(fp)));
  std::istream in (&fpstream);

You could also avoid the intermediate stream_buffer by simply writing:

  stream<file_descriptor_source> in(file_descriptor_source(fileno(fp)));

instead, because a boost::iostreams::stream<something_that_is_a_source> inherits from std::istream

(BTW, don't forget to fclose()!)

> Excuse me , but I don't know well the C++...

No problem, it happened even to the best here :)

> OT
> How can I move this question in "user" mailing list?
> /OT


Boost list run by bdawes at, gregod at, cpdaniel at, john at