Ticket #5183: IntrusiveTest.C

File IntrusiveTest.C, 721 bytes (added by johannes.gajdosik@…, 12 years ago)

Demonstrate safe_link failure of replace_node

Line 
1#include <boost/intrusive/avl_set.hpp>
2#include <iostream>
3
4using namespace boost::intrusive;
5using namespace std;
6
7typedef avl_set_base_hook<
8 link_mode<safe_link>,
9 optimize_size<false> > Hook;
10
11struct X : public Hook {
12 X(int t) : t(t) {}
13 int t;
14 bool operator<(const X &v) const {return t < v.t;}
15};
16
17typedef avl_set<X> Set;
18
19int main(int argc,char *argv[]) {
20 {
21 X w(2);
22 {
23 X v(2);
24 {
25 Set set;
26 set.insert(v);
27 set.replace_node(Set::s_iterator_to(v),w);
28 set.clear();
29 cout << "destructing set" << endl;
30 }
31 cout << "destructing v" << endl;
32 }
33 cout << "destructing w" << endl;
34 }
35 cout << "bye." << endl;
36 return 0;
37}