Boost logo

Boost Users :

Subject: Re: [Boost-users] ptr_map<U, T> with polymorphic U
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2012-11-08 05:46:11


On 07-11-2012 19:02, Victor Snyder wrote:
> ptr_map<U, T> lets me map simple types to pointers-to-T,
> preserving polymorphic behavior of the mapped-to objects, and clearly
> stating that the ptr_map solely owns the pointed-to objects.
>
> I'd like to map pointers-to-U to pointers-to-T and have the map solely
> own the key objects as well as the mapped-to objects. ptr_map doesn't
> do this. I could map shared_ptrs-to-U to pointers-to-T, but then I lose
> the clear ownership semantics.
>
> Does anyone know of an easy workaround to get the behavior and semantics
> that I want, or is this more properly a feature request?

I don't know of an easy way. You're welcome to suggest it, but its not a
trivial update to ptr_map.

Perhaps something like

typedef ptr_array<T,1> Key:
typedef ptr_map<Mey,U> Map;

would work? Let us know if this is an option.

-Thorsten


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net