From -8288405101149103261 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,eaf633a917dfd8af X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 2003-11-09 11:01:21 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull From: andreytarasevich@hotmail.com (Andrey Tarasevich) Newsgroups: comp.std.c++ Subject: Re: Passing functor-parameters in for_each() and transform() Date: Sun, 9 Nov 2003 19:01:20 +0000 (UTC) Organization: Posted via Supernews, http://www.supernews.com Lines: 32 Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++) Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: mail2news.demon.co.uk 1068404480 12463 10.0.0.1 (9 Nov 2003 19:01:20 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 9 Nov 2003 19:01:20 +0000 (UTC) X-Received: from mulga.cs.mu.oz.au ([128.250.1.22]) by news.demon.co.uk with esmtp (Exim 4.12) id 1AIuoJ-0003Es-00 for mail2news@news.news.demon.net; Sun, 09 Nov 2003 19:01:20 +0000 X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU id GAA01829; Mon, 10 Nov 2003 06:01:16 +1100 (EST) X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Path: comp-std-cpp-robomod!not-for-mail X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-Delivered-To: std-c++@ucar.edu X-Newsgroups: comp.std.c++ X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en X-Spam-Status: No, hits=-5.3 required=5.0 tests=AWL,BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES,SEMIFORGED_HOTMAIL_RCVD, USER_AGENT_MOZILLA_UA version=2.55 X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) Xref: archiver1.google.com comp.std.c++:404 Alex Vinokur wrote: > ... > Functor-parameters in the for_each() and transform() algorithms are passed by value. > > Might it make sense to have also algorithms for_each2() and transform2() > which pass Functor-parameters by non-const reference? > ... You can work around this limitation by using explicit specification of template arguments, although everyone will probably agree that this method cannot be referred to as "elegant" ... transform::iterator, vector::iterator, vector::iterator, Foo&>(x.begin(), x.end(), y.begin(), vect_.begin(), *this); ... for_each::iterator, Foo&>(vect_.begin(), vect_.end(), *this); ... -- Best regards, Andrey Tarasevich --- [ 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 ]