bug in istream.get(b,c,d) ?

Loren James Rittle rittle@latour.rsch.comm.mot.com
Wed Sep 18 16:34:00 GMT 2002


>> Consider (line at a time version of cat
>> which alway adds a final newline if not present):

> Or even easier and more efficient:

> #include <iostream>
> #include <fstream>
>
> int main (int argc, char *argv[])
> {
>     for (int i = 1; i < argc; ++i)
>         std::cout << std::ifstream (argv [i], std::ios::in).rdbuf ();
> }

OK, most agreed.  However, I did retain the assumption that he wanted
visibility into "line at a time" instead of block processing. ;-)

For absolute maximal efficiency on all libstdc++-v3 ports, also add
this line (to either example):

  std::ios::sync_with_stdio (false);

BTW, although it may appear otherwise in this e-mail, I would never
challenge Martin to an optimization contest.

Regards,
Loren



More information about the Libstdc++ mailing list