Boost logo

Boost Users :

From: sashan (sashang_at_[hidden])
Date: 2002-04-25 18:09:54


Hi

Why does the operator == function in the shared_ptr class compare the pointer values and not what they are pointing to?

I'm trying to use the find function (in the stl) and I don't know how to get around this. Here's an example.

vector <shared_ptr <SomeClass> > vecStuff;
shared_ptr<SomeClass> pkToFind(new SomeClass(x,y,z));

if (find(vecStuff.begin(), vecStuff.end(), pkToFind) != vecStuff.end())
{

}

This didn't work as expected because the shared_ptr class's operator== function does not use SomeClass's operator == function to do the comparison. Instead it compares the pointer values. I don't understand why they made it like this and I don't think they were dumb enough to overlook this so there must be something I'm missing.

Thanks

Sashan

[Non-text portions of this message have been removed]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net