| 1 | #include <boost/intrusive/avl_set.hpp>
|
|---|
| 2 | #include <iostream>
|
|---|
| 3 |
|
|---|
| 4 | using namespace boost::intrusive;
|
|---|
| 5 | using namespace std;
|
|---|
| 6 |
|
|---|
| 7 | typedef avl_set_base_hook<
|
|---|
| 8 | link_mode<safe_link>,
|
|---|
| 9 | optimize_size<false> > Hook;
|
|---|
| 10 |
|
|---|
| 11 | struct 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 |
|
|---|
| 17 | typedef avl_set<X> Set;
|
|---|
| 18 |
|
|---|
| 19 | int 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 | }
|
|---|