[intrusive] how to change the value of an item in a set?

Hello,
namespace bi = boost::intrusive;
typedef bi::set

Raymond Haeb wrote:
Hello, [snip]
So the question is in the comment: Is there a way to change the value of an element of a set or insert an (new) element in a set, without having a pointer to the set?
No, sorry. To insert a value in a set you need access to the predicate, which is stored in the set. In case the predicate is stateless and the constant_time_size is false (as your example shows) I think it's possible to implement an static function that removes the node, climbs up to the root node of the tree and inserts the new node. Note that if your predicate throws, the insertion might fail, and your node would be left unlinked. And the function would be really low-level and dangerous if used without care. I don't know if this has some deep impact in current design, but I will try to see it when I have a bit of time. Meanwhile, I'm afraid you'll need a pointer to the set ;-) Regards, Ion
participants (2)
-
Ion Gaztañaga
-
Raymond Haeb