Sorry I mistyped by previous email slightly - my_node_t derives from avl_set_base_hook<> as below:


I'm trying to come to grips with using the boost intrusive containers, but I don't think I understand how the lifetime of hooks need to be managed. This piece of code fails the !hook.is_linked() assertion:
Any pointers? Also, is there is a non-intrusive AVL tree container as part of boost?

struct my_node_t : public avl_set_base_hook<> {
    int i_;
    my_node_t(int i): i_(i) {}
   
    friend bool operator<(const my_node_t& lhs, const my_node_t& rhs)  {
        return lhs.i_ < rhs.i_;
    }

   friend ostream& operator<< (ostream& os,  const my_node_t& n) {
       return os << n.i_;
   }
};

int main() {
   avltree<my_node_t> tree;
   vector<my_node_t> vec;
   for (int i = 0; i < 10; ++i) vec.push_back(my_node_t(i));
   for (int i = 0; i < 10; ++i) tree.insert_unique(vec[i]));
   copy(tree.begin(), tree.end(), ostream_operator<my_node_t>(cout, " ");
}
 


text