Boost logo

Boost :

From: Brian Riis (brian_at_[hidden])
Date: 2004-10-13 19:32:32

Hi list,

I have a situation where I need to find a tuple from a vector based on
the value of one of the tuple's values.

vector<tuple<string, int, int> > v;

Basically I need the last int, and all I'm supplied is the first int. I
thought of using lambda expressions for this, and dug into the
documentation for that (so, this is my first real experience with
BLL...and any lambda expressions for that matter).

After some experimentation, I ended up with something akin to this.

typedef boost::tuple<std::string, int, int> myTuple;
std::vector<myTuple> v;
using namespace boost::lambda;
int id = <the value for the first int, that I need to find>

std::vector<myTuple>::iterator iter =
   std::find_if(v.begin(), v.end(),
     (bind(&myTuple::get<1>, _1) == id));

My compiler (MinGW-3.4.2) gives me an error message on that last line:
"error: cannot resolve overloaded function `get' based on conversion to
type `SOCKET'"

I'm sure it's trying to tell me where I've messed up, but I can really
see it. (no doubt it's due to lack of experience with BLL, or lack of
intelligence; quite possibly both :))

Am I totally out to sea here? If so, I'd be joyous if someone would
light a beacon for me! :)


  /Brian Riis

Boost list run by bdawes at, gregod at, cpdaniel at, john at