 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Fraser Ross Guest
|
Posted: Mon Aug 25, 2003 4:48 pm Post subject: new algorithm |
|
|
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 ]
|
|
| Back to top |
|
 |
Michiel Salters Guest
|
Posted: Tue Aug 26, 2003 8:52 pm Post subject: Re: new algorithm |
|
|
[email]fraser (AT) members (DOT) v21.co.uk[/email] ("Fraser Ross") wrote in message news:<003601c36ae4$4c556b20$594279d5@frasercomputer>...
| Quote: | 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 ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|