Topic: new algorithm
Author: fraser@members.v21.co.uk ("Fraser Ross")
Date: Mon, 25 Aug 2003 16:48:07 +0000 (UTC) Raw View
I wished to use transform with an out iterator equal to one of the input
iterators. I realised what I want is something more akin to for_each but
with an extra iterator parameter and a necessary binary_op parameter. Does
anyone agree that this is useful and should be a standard algorithm?
BinaryOperation transform_each(InputIterator1 first1,
InputIterator1 last1,
InputIterator2 first2,
BinaryOperation binary_op);
first1 to last1 elements can be modified via a reference, and theres no need
for construction of a temporary and copy assignment as with transform. This
is also easier than using for_each with a complex functor.
Fraser.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: Michiel.Salters@cmg.nl (Michiel Salters)
Date: Tue, 26 Aug 2003 20:52:35 +0000 (UTC) Raw View
fraser@members.v21.co.uk ("Fraser Ross") wrote in message news:<003601c36ae4$4c556b20$594279d5@frasercomputer>...
> I wished to use transform with an out iterator equal to one of the input
> iterators. I realised what I want is something more akin to for_each but
> with an extra iterator parameter and a necessary binary_op parameter. Does
> anyone agree that this is useful and should be a standard algorithm?
>
>
> BinaryOperation transform_each(InputIterator1 first1,
> InputIterator1 last1,
> InputIterator2 first2,
> BinaryOperation binary_op);
>
> first1 to last1 elements can be modified via a reference, and theres no need
> for construction of a temporary and copy assignment as with transform. This
> is also easier than using for_each with a complex functor.
I wonder if there's a large benefit here, anyone could write it provided
they realized that InputIterator1 would actually have to be a
ForwardIterator (since it's also used for Output).
The only benefit I could see is that a std:: version could use the std::'s
concept check system to verify that binary_op's types are correct, if
the Standard Library has such a framework in place.
Regards,
--
Michiel Salters
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]