 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Drew Guest
|
Posted: Tue Oct 28, 2003 2:11 am Post subject: Using find_if with member function |
|
|
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
|
Posted: Wed Oct 29, 2003 4:32 pm Post subject: Re: Using find if with member function |
|
|
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
|
Posted: Fri Oct 31, 2003 1:39 am Post subject: Re: Using find_if with member function |
|
|
[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 |
|
 |
|
|
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
|
|