Boost logo

Boost Users :

Subject: Re: [Boost-users] [ptr_container] Abstract Key type in ptr_map< Key, Val> impossible?
From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2010-06-29 11:42:32


Mikhail Levin skrev:
> Steven Watanabe <watanabesj <at> gmail.com> writes:
>> I believe that ptr_map stores the key be value.
>>
>> In Christ,
>> Steven Watanabe
>>
>
> I see. Thank you.
>
> It would be good to document this prominently, because it is natural to expect
> that ptr_map<Key,Val> stores Key*, since "a set can be seen as a map, where
> values are irrelevant" and ptr_set<Key> stores Key*.

It should be somewhat clear from the examples, and other documentation.

There are several options that you may employ:

A) use shared_ptr<const Key> as key

B) use std::map<shared_ptr<const Key>,value>

-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