Boost logo

Boost :

Subject: Re: [boost] [paired ptr] Proposing a new smart pointer object for managing bidirectional relationships between objects
From: Vicente Botet Escriba (vicente.botet_at_[hidden])
Date: 2010-05-03 11:14:05

Dan Walters-2 wrote:
> Dear all,
> I have been working on a proposal for a useful utility for managing
> non hierarchal, bi-directional relationships between objects and as a
> useful tool in object composition.
> This utility is in the form of a type of templated smart pointer that
> can connect to one single other pointer and manage the relationship
> between the two pointers.
> This paired_ptr object is intended for use as a member of (or at least
> contained within) a user defined object and is conceptualized from the
> needs of object composition.
> Prototype source code, a usage example and brief documentation is
> available here:
> Doumentation only is available here: (this is a google doc and is
> continually being updated)
> I am posting here in the hope it will generate suitable interest that
> it may be worth developing as a full library for submission.
> Best wishes,
> Dan
> _______________________________________________
> Unsubscribe & other changes:


I don't know why I don't like the name paired_ptr, one_to_one_ptr could be
an alternative. I will see this class as one more in a Association library
that could include other kind of associations, as one_to_many, many_to_one,

class CCat

CDog rex;
CCat kitty;

As no one side of the association is more important than the other maybe a
non-member function could be more adequate. The connection between two
objects can be established as so

connect(rex.paired_cat, kitty.paired_dog);

//connections can be severed at either end

have you think about adding a mixin paired_ptr that can be used as base
class and as such don't need to manage with the owner initialization?

class CCat;
class CDog;

class CDog : public one_to_one_ptr<CDog, CCat>

class CCat : public one_to_one_ptr<CCat,CDog>

Now the connection can be done directly
connect(rex, kitty);

one_to_one_ptr<T,U> could define a method to get the pointed U, get<U> that
can be used like





View this message in context:
Sent from the Boost - Dev mailing list archive at

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