
Hello, I was wondering if there's interest in a smart pointer, which is able to cope with circular references. I think it would make a nice addition to the smart_ptr classes already in boost. I have a library almost ready, which can solve the problem where: - class A contains a pointer to class B - class B contains a pointer to class A - and it is not known wether the "master" of these two is A or B. With "master", I mean which pointer is the pointer that is kept alive from the execution thread. For example, if we would implement this with shared_ptr and weak_ptr, we would most likely have the following: - class A contains a shared_ptr to class B - class B contains a weak_ptr to class A - the execution thread contains a shared_ptr Ptr to class A. In this case, if I where to assign Ptr = B, A would be erased, since A no longer is referenced (weak_ptr references don't count reference-counter wise). The code I have aims to solve this problem, by using two types of pointers. The execution thread will work with boost::intrusive_ptr (which are allocated on the stack) while classes wishing to point to other classes, will use a new type of pointer (named 'reference') that I designed. This pointer is aware of the owner of the pointer, in addition of the object it points to. The implementation uses only standard C++ code, with some help from boost (notably boost::intrusive_ptr and, in the case of multithreading environments, boost::thread). Anyways, I am wondering if people are interested. :) Can't imagine that it wouldn't be of use to at least some of you. ;) For status info: I am currently ironing out some minor bugs and implementing STL-type collection classes (like the equivalent of a std::list<MyClass*> ) for these pointers, as they have non-standard initialization semantics. Ariane