This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project. See the libstdc++ home page for more information.


[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index] [Subject Index] [Author Index] [Thread Index]

Re: what am I doing wrong?



 
> I'm trying to install and use the 2.90.1 snapshot, purely because the 
> [io]streambuf_iterators are implemented, on a Solaris 2.6 system using egcs 
> 1.1.  Downloaded the library today and it built okay, but I never got as far 
> as linking against the resulting files.

That snapshot isn't really intended for use, just for inspection.

> The idea is to 
> quickly and completely portably copy a file, so what I want, ideally, is
> 
> 	// given an ifstream& IN and ofstream& OUT for this email
> 	copy (istreambuf_iterator (IN),
> 	      istreambuf_iterator (),
> 	      ostreambuf_iterator (OUT));
> 
> I know there are only about a million ways to copy a file "completely 
> portably" in C++, but I was hoping for something short and elegant.  :-)

The most elegant way I know of to copy a file is

  OUT << IN.rdbuf();

Nathan Myers
ncm@cantrip.org