[C++-sig] Is there a way to automatically convert a smart_ptr to a held_type (try 2)

Alex Mohr amohr at pixar.com
Thu Sep 7 18:55:05 CEST 2006


> The non-obvious part of this for me is:
> 
> - Does this mean that I now need to explicitly wrap (expose using
> bp::class_ ) all the ref_ptr<>  types?
> 
> I haven't had to do that thus far because it was handled internally
> somehow because I used it has the held_type for all my classes.  If I
> expose them manually do I run the risk of breaking any of the
> held_type functionality?

I'm not sure what you mean...  If ref_ptr<T> is the held type for T, 
then just provide __eq__ in terms of ref_ptr<T>...

template <class T>
static bool ref_ptr_eq(ref_ptr<T> const &self, ref_ptr<T> const &other)
{
     return self == other;
}

class_<T, ... ref_ptr<T> ... >(...)
     .def("__eq__", ref_ptr_eq<T>)
     ;

Am I misunderstanding your situation?

Alex



More information about the Cplusplus-sig mailing list