Re: [boost] Addition for shared_ptr

Michael Rutman wrote:
At 1:40 PM +0300 9/20/04, Peter Dimov wrote:
Michael Rutman wrote:
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 );
This is a reasonable suggestion. It turns out that std::find _is_ specified in a way that allows heterogeneous comparisons, although this may be an oversight on the part of the committee and not a design decision. ;-)
Any chance this can go in for the next release?
<tilts head and ponders for a moment> Probably not, but not because it's necessarily a bad idea. I only add extensions to components already in TR1 if I'm reasonably sure that I want to (formally) propose this extension for a later version of the component (TR2, or C++next). Which in this case I'm not (yet).
participants (1)
-
Peter Dimov