1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2009-2013. Distributed under the Boost
4// Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// See http://www.boost.org/libs/container for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10
11//[doc_recursive_containers
12#include <boost/container/vector.hpp>
13#include <boost/container/stable_vector.hpp>
14#include <boost/container/deque.hpp>
15#include <boost/container/list.hpp>
16#include <boost/container/map.hpp>
17#include <boost/container/string.hpp>
18
19using namespace boost::container;
20
21struct data
22{
23 int i_;
24 //A vector holding still undefined class 'data'
25 vector<data> v_;
26 vector<data>::iterator vi_;
27 //A stable_vector holding still undefined class 'data'
28 stable_vector<data> sv_;
29 stable_vector<data>::iterator svi_;
30 //A stable_vector holding still undefined class 'data'
31 deque<data> d_;
32 deque<data>::iterator di_;
33 //A list holding still undefined 'data'
34 list<data> l_;
35 list<data>::iterator li_;
36 //A map holding still undefined 'data'
37 map<data, data> m_;
38 map<data, data>::iterator mi_;
39
40 friend bool operator <(const data &l, const data &r)
41 { return l.i_ < r.i_; }
42};
43
44struct tree_node
45{
46 string name;
47 string value;
48
49 //children nodes of this node
50 list<tree_node> children_;
51 list<tree_node>::iterator selected_child_;
52};
53
54
55
56int main()
57{
58 //a container holding a recursive data type
59 stable_vector<data> sv;
60 sv.resize(n: 100);
61
62 //Let's build a tree based in
63 //a recursive data type
64 tree_node root;
65 root.name = "root";
66 root.value = "root_value";
67 root.children_.resize(new_size: 7);
68 root.selected_child_ = root.children_.begin();
69 return 0;
70}
71//]
72

source code of boost/libs/container/example/doc_recursive_containers.cpp