C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

new algorithm

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Fraser Ross
Guest





PostPosted: Mon Aug 25, 2003 4:48 pm    Post subject: new algorithm Reply with 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.

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





PostPosted: Tue Aug 26, 2003 8:52 pm    Post subject: Re: new algorithm Reply with quote



[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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.