1

Just for better understanding, can I replace the call to boost::bind in the following example with std::bind1st/2nd? Or is it not possible because of returning a reference?

Example(shortened):

class Pos
{
public:
bool operator==( const Pos& );
...
}

class X
{
public:
const Pos& getPos()  { return m_p; }
...
private:
Pos m_p;
}

...
Pos position;
std::vector<X> v;
std::vector<X>::iterator iter;
...

iter = std::find_if( v.begin(), v.end(), boost::bind( &X::getPos, _1 ) == position );
...
name
  • 11
  • 4

1 Answers1

3

It's not possible, because neither bind1st nor bind2nd overloads operator== like bind does (to yield another functor). If you don't want to use bind, you need to write the functor yourself, or use a lambda.

Cat Plus Plus
  • 125,936
  • 27
  • 200
  • 224
  • Thanks. After measuring using a function object turns out to be fastest for the target system any way. – name Oct 26 '11 at 16:35