"tom_usenet" <> wrote in message news:...
> On Tue, 20 Apr 2004 14:47:57 +0300, "Alex Vinokur"
> <> 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
private.php?do=newpm&u=
http://mathforum.org/library/view/10978.html