Question

For my application, it is much more convenient and logical to hold a map of websocketpp::connection_hdls as keys in a map, but I've found that this could be potentially dangerous since they are weak_ptrs.

However, it's been claimed that a boost::unordered_map may not break if a weak_ptr key expires.

Is that true? If so, how can one be constructed to hold connection_hdls as keys as well as be inserted, erased, and found/counted? Also, what is necessary to be able to loop through them, such as with a for?

This is currently beyond my skillset, so I'm unsure of what I'm looking at.

Was it helpful?

Solution

boost::unordered_map could be slow on iteration, thus, I would suggest that you could store all websocketpp::connection_hdl in a std::vector. For the map you can use pointers as keys: boost::unordered_map<websocketpp::connection_hdl*, X>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top