RE: [Boost-Users] find_if and calling a member function
Define easier :) Not to be picky, but how little do you expect to have to type? 1) write your own algorithm find_if_equal, then you only need one bind (~10 lines of code separate from your call) 2) write a functor, ObjectNameCompare (less than 15 lines of code separate from your call)
-----Original Message----- From: Russell Hind [mailto:yg-boost-users@gmane.org] Sent: Tuesday, May 13, 2003 9:31 AM To: boost-users@yahoogroups.com Subject: [Boost-Users] find_if and calling a member function
I have an object that has a member get_name which returns a string. I have a collection of these objects and would like to find one with a particular name. I am currently using find_if, equal and bind
find_if(objects.begin(), objects.end(), bind(equal_to<string>(), name, bind(&object::get_name, _1)));
Given Lambda doesn't compile under BCB6, is there an easier way to do this rather than having to make up 2 bind statements?
Thanks
Russell
------------------------ Yahoo! Groups Sponsor ---------------------~--> Rent DVDs Online - Over 14,500 titles. No Late Fees & Free Shipping. Try Netflix for FREE! http://us.click.yahoo.com/YoVfrB/XP.FAA/uetFAA/EbFolB/TM -------------------------------------------------------------- -------~->
Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
----------------------------------------------------------------------- DISCLAIMER: Information contained in this message and/or attachment(s) may contain confidential information of Zetec, Inc. If you have received this transmission in error, please notify the sender by return email. -----------------------------------------------------------------------
Tom Matelich wrote:
Define easier :) Not to be picky, but how little do you expect to have to type?
Sorry, don't have the Oxford Dictionary with me at the moment :)
1) write your own algorithm find_if_equal, then you only need one bind (~10 lines of code separate from your call)
This is what I was looking for, and I was really wondering (although didn't say it) if there were such a thing in boost already. I haven't found one, but there are quite a few bits of boost I'm not familiar with yet.
2) write a functor, ObjectNameCompare (less than 15 lines of code separate from your call)
The get name was just an example, so I think the above approach will be more flexible. Thanks Russell
participants (2)
-
Russell Hind
-
Tom Matelich