Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #9442

Re: Create an istream from an fd?

From Nobody <nobody@nowhere.com>
Subject Re: Create an istream from an fd?
Date 2011-08-29 20:12 +0100
Message-Id <pan.2011.08.29.19.12.39.670000@nowhere.com>
Newsgroups comp.lang.c++
References (3 earlier) <j39ep8$tv5$1@dont-email.me> <9btaq6FopsU5@mid.individual.net> <2be71f2e-9a18-42ab-a7ec-bc7f8ccb215e@i9g2000yqk.googlegroups.com> <pan.2011.08.28.03.31.29.633000@nowhere.com> <3173046d-6a90-4c8d-96ab-4f0b66a85104@n12g2000yqh.googlegroups.com>
Organization Zen Internet

Show all headers | View raw


On Mon, 29 Aug 2011 03:54:01 -0700, James Kanze wrote:

>> It could have required a version of filebuf::open() (or similar) taking
>> a FILE*, given that <cstdio> is part of the standard.
> 
> That's probably not a good idea.  It would force the
> implementation of filebuf to be based on FILE*, which is not a
> good thing.

That's why I added " (or similar) ". There has to be some form of
streambuf (which may or may not be filebuf) which is used for cin etc.

>> And, realistically, most of the machinery is likely to be in
>> place in order to implement cin/cout/cerr/clog. Given the
>> existence of ios::sync_with_stdio(), it seems like it would be
>> quite hard to implement this in a way that didn't facilitate
>> creating some kind of streambuf from a FILE*.
> 
> Not really.  All sync_with_stdio means is that you have to call
> fflush() before each output.

Which would mean that cout etc have to be able to get a FILE* to pass to
fflush().

But my point remains that you'd have to go out of your way to implement
cin etc in such a way that providing a way to create a streambuf from an
arbitrary FILE* would be significant extra work.

Sure, the programmer can implement something themselves. But given how
many programs will end up needing this (how many C++ programs use
third-party libraries which use FILE*?), it seems like an oversight.

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Create an istream from an fd? Noah Roberts <roberts.noah@gmail.com> - 2011-08-26 08:54 -0700
  Re: Create an istream from an fd? Leigh Johnston <leigh@i42.co.uk> - 2011-08-26 17:05 +0100
  Re: Create an istream from an fd? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-26 12:20 -0400
  Re: Create an istream from an fd? Vaclav Zeman <vzeman79@sh.cvut.cz> - 2011-08-26 18:34 +0200
  Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-27 08:48 +1200
  Re: Create an istream from an fd? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-27 01:26 +0200
    Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-27 11:30 +1200
      Re: Create an istream from an fd? "Alf P. Steinbach" <alf.p.steinbach:usenet@gmail.com> - 2011-08-27 02:46 +0200
        Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 10:52 +1200
          Re: Create an istream from an fd? James Kanze <james.kanze@gmail.com> - 2011-08-27 16:35 -0700
            Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-28 04:31 +0100
              Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 15:56 +1200
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-28 20:03 +0100
                Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-29 07:52 +1200
              Re: Create an istream from an fd? James Kanze <james.kanze@gmail.com> - 2011-08-29 03:54 -0700
                Re: Create an istream from an fd? Leigh Johnston <leigh@i42.co.uk> - 2011-08-29 13:55 +0100
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-29 20:12 +0100
                Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-30 07:49 +1200
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-30 04:40 +0100
                Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-30 15:51 +1200
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-31 00:03 +0100
                Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-31 11:55 +1200
                Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-09-02 00:50 +0100
            Re: Create an istream from an fd? Ian Collins <ian-news@hotmail.com> - 2011-08-28 16:04 +1200
  Re: Create an istream from an fd? Nobody <nobody@nowhere.com> - 2011-08-27 02:40 +0100

csiph-web