I may need to rethink my overall design a bit more, but as it stands, it looks like I may want to do something like:
class A;
class B;
std::map<boost::shared_ptr<const A>, B> APtrToBMap;
I've tried this, and it does seem to work in a simple case (the compiler didn't complain, and simple tests seem to work). But I'm having second thoughts about this approach. I suspect there are some gotchas in there that I'm not aware of.
So, is the above valid in a practical sense? Or is there some flaw I'm not aware of when I do this?
The reference has this to say:
template<class T, class U>
bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b); // never throws
Returns: an unspecified value such that
Throws: nothing.
Notes: Allows shared_ptr objects to be used as keys in associative containers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With