Re: [Boost-bugs] [Boost C++ Libraries] #3517: [iostreams] stream<file_descriptor_source> closes supplied descriptor

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3517: [iostreams] stream<file_descriptor_source> closes supplied descriptor
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-06-15 08:10:46

#3517: [iostreams] stream<file_descriptor_source> closes supplied descriptor
 Reporter: Alexander Churanov <alexanderchuranov+boost@…> | Owner: turkanis
     Type: Bugs | Status: new
Milestone: Boost 1.41.0 | Component: iostreams
  Version: Boost 1.39.0 | Severity: Problem
 Keywords: |

Comment(by danieljames):

 I think you're right, but I feel cautious about silently changing existing
 behaviour. I also dislike the boolean parameter. So I'd create a new
 constructor which takes flags to indicated if the handle should be closed.
 And maybe `close_on_exit` if someone wants it. I'd deprecate the existing
 constructor, so that it's only present if a macro is defined. That way
 we'd break the compile rather than subtly changing the code. What do you
 think of something like this? Am I being over-cautious?

 namespace boost { namespace iostreams {

 enum file_handle_flags {
     close_handle, // maybe owns_handle?
     close_handle_on_exit // Probably shouldn't be public.

 class file_descriptor {
     typedef char char_type;
     typedef [implementation-defined] category;
     file_descriptor( const std::string& pathname,
                      std::ios_base::open_mode mode =
                          std::ios_base::in | std::ios_base::out );

     file_descriptor( int fd, file_handle_flags);

     // Windows-only
     file_descriptor( HANDLE hFile, file_handle_flags);

 // Maybe something with a version number...
     file_descriptor( int fd, bool close_on_exit = false );

     // Windows-only
     file_descriptor( HANDLE hFile, bool close_on_exit = false );

     bool is_open() const;

 } } // End namespace boost::io


 It'll be more verbose but I think it's worth it to clear up the ambiguity.
 Oh, and those constructors should probably have been `explicit`.

Ticket URL: <>
Boost C++ Libraries <>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC