Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > istream_iterator & copying files

Reply
Thread Tools

istream_iterator & copying files

 
 
Alex Vinokur
Guest
Posts: n/a
 
      04-20-2004

"tom_usenet" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> On Tue, 20 Apr 2004 14:47:57 +0300, "Alex Vinokur"
> <(E-Mail Removed)> wrote:
>
> >-------------------------------
> >> std::copy( in, eos, out );

> > Is it possible to that via transform()?

>
> std::copy is equivalent to std::transform with the identity function.
> So what would be the point of using std::transform where std::copy
> suffices?


To compare their performances.

>
> (if you must:
>
> template <class T>
> struct identity
> {
> T operator(T t) const
> {
> return t;
> }
> };
>
> Then
> std::transform(in, eos, out, identity<char>());
> )

[snip]

OK.

---------------------------
istreambuf_iterator<char> in(fs_in), eos;
ostreambuf_iterator<char> out(fs_in);
fs_bin_in >> noskipws;

// copy-method
copy (in, eos, out);

// transform-method
struct char_identity
{
char operator()(char ch) const { return ch; }
};
transform(in, eos, out, char_identity());
---------------------------

copy-method and transform-method have almost the same performance.
It seems that copy-method is a bit better, but perhaps is a metering error.


--
Alex Vinokur
(E-Mail Removed)
http://mathforum.org/library/view/10978.html





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
about istream_iterator ben C++ 2 05-18-2005 03:39 AM
Copying with istream_iterator Alex Vinokur C++ 9 07-24-2004 06:45 AM
istream_iterator<> NPC C++ 3 05-14-2004 11:41 AM
istream_iterator and ostream_iterator problem Chris Mantoulidis C++ 2 12-15-2003 12:14 PM
istream_iterator question Bill Rudolph C++ 4 08-15-2003 07:28 AM



Advertisments