[ptr_container] Abstract Key type in ptr_map<Key, Val> impossible?

Hello,
The following code would not compile.
struct Key {
bool operator<(const Key&) const;
virtual void blah() const = 0;
};
struct Val {
/* */
};
boost::ptr_map

AMDG Mikhail Levin wrote:
The following code would not compile.
struct Key { bool operator<(const Key&) const; virtual void blah() const = 0; };
struct Val { /* */ };
boost::ptr_map
map; Although boost::ptr_set<Key> set; seems to work.
I believe that ptr_map stores the key be value. In Christ, Steven Watanabe

Steven Watanabe
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

Mikhail Levin skrev:
Steven Watanabe
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
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
participants (3)
-
Mikhail Levin
-
Steven Watanabe
-
Thorsten Ottosen