Subject: Re: [boost] Standard stream from C fopen()
From: Daniel James (dnljms_at_[hidden])
Date: 2010-11-14 10:27:24


On 13 November 2010 06:11, Claude <clros_at_[hidden]> wrote:
>
> Uhmm
>
> I obtain always this error:
>
> error: call of overloaded ‘path(const int&)’ is ambiguous|

The library changed in 1.44, you now need to explicitly specify if you
want the file_descriptor to be automatically closed.

    namespace io = boost::iostreams;

    io::stream<io::file_descriptor_source> in(
        handle, io::close_handle);

And the handle will be closed when in is destructed, or you call
'in.close()'. Or if you want to close it yourself:

    io::stream<io::file_descriptor_source> in(
        handle, io::never_close_handle);

    // later...

    close(handle);

Note that with 'never_close_handle', the handle isn't closed even if
you call the 'in.close()'. This is because otherwise some generic code
can call 'in.close' and close the file when it shouldn't be closed.

Daniel