Boost logo

Boost :

From: Michael Rutman (moose_at_[hidden])
Date: 2004-09-16 15:34:17

I'd like to propose adding a template function to shared_ptr to allow the
automatic testing of a shared_ptr to its raw ptr.

The template is as simple as

template <class T>
bool operator==(boost::shared_ptr<T> const & a, T * const & b)
    return a.get() == b;

Here is the case where I need it.

I have a vector<Foo> myFoo.

In a method of Foo I need to see if this instance is in the vector. I want
to do this

vector<Foo>::iterator iter = find( myFoo.begin(), myFoo.end(), this );

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