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 

Using find_if with member function

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Drew
Guest





PostPosted: Tue Oct 28, 2003 2:11 am    Post subject: Using find_if with member function Reply with quote



I am attempting to call a virtual function of a class that returns
true or false based on whether or not the record passed in is equal to
the current record.

find_if(m_records.begin(), m_records.end(), bind2nd(&VirtualFunction,
pRecord) );

The other tricky part to the equation is that boost::intrusive_ptr's
are stored in the list.

Any ideas on how to accomplish this task?

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Andreas Mueller
Guest





PostPosted: Wed Oct 29, 2003 4:32 pm    Post subject: Re: Using find if with member function Reply with quote



Drew schrieb:

Quote:
I am attempting to call a virtual function of a class that returns
true or false based on whether or not the record passed in is equal
to the current record.

find_if(m_records.begin(), m_records.end(), bind2nd(&VirtualFunction,
pRecord) );

The other tricky part to the equation is that boost::intrusive_ptr's
are stored in the list.

Any ideas on how to accomplish this task?

As you are using boost, take a look at
http://www.boost.org/libs/bind/mem_fn.html
HTH
Andy


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Peter Dimov
Guest





PostPosted: Fri Oct 31, 2003 1:39 am    Post subject: Re: Using find_if with member function Reply with quote



[email]drewtenn (AT) yahoo (DOT) com[/email] (Drew) wrote in message news:<f7224304.0310271007.404a895 (AT) posting (DOT) google.com>...
Quote:
I am attempting to call a virtual function of a class that returns
true or false based on whether or not the record passed in is equal to
the current record.

find_if(m_records.begin(), m_records.end(), bind2nd(&VirtualFunction,
pRecord) );

The other tricky part to the equation is that boost::intrusive_ptr's
are stored in the list.

You just need to use the right "bind". :-)

find_if(m_records.begin(), m_records.end(),
boost::bind(&Class::VirtualFunction, _1, pRecord) );

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) 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.