Boost logo

Boost :

From: Rainer Deyke (root_at_[hidden])
Date: 2002-03-19 11:03:16


----- Original Message -----
From: "Dylan Nicholson" <dylan_nicholson_at_[hidden]>
To: "boost list" <boost_at_[hidden]>
Sent: Monday, March 18, 2002 10:37 PM
Subject: [boost] Remarkably efficient file copy

> If we definitely decide to put in a "copy_file" routine into
boost::filesystem,
> then believe it or not, the following single line of code is
remarkably
> efficient (at least under HP aCC 3.33, which is what I tested it
with):
>
> bool copy(const char* src, const char* dest)
> {
> return std::ofstream(dest) << std::ifstream(src).rdbuf();
> }

It's also subtly incorrect. Both streams need to be opened in binary
mode.

--
Rainer Deyke | root_at_[hidden] | http://rainerdeyke.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk