
On Wednesday 18 July 2012 08:01:09 Amir Ansari wrote:
2. Is there some specialization for flat_set with the same semantics as ptr_vector ?
I'm not sure I understand. Do you intend to store pointers in flat_set? If so, you can store std::unique_ptr's or shared_ptr's and specify your custom ordering predicate to order pointers by their pointees.
The documentation for boost::ptr_vector says that using the smart pointers inside a vector isn't ideal... it's one of the reasons why ptr_vector exists. I was wondering if that logic applies still when flat_set holds pointers and is there a solution available?
If you have unique_ptr, standard containers can hold exclusive pointers, which practically defeats the efficiency penalty of storing shared_ptr's. Pointer containers also provide other features but if all you need is store pointers in containers, unique_ptr and STL containers are enough. The same applies to flat_set.