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 #include <boost/container/detail/config_begin.hpp> 11 #include <boost/container/detail/workaround.hpp> 12 //[doc_recursive_containers 13 #include <boost/container/vector.hpp> 14 #include <boost/container/stable_vector.hpp> 15 #include <boost/container/deque.hpp> 16 #include <boost/container/list.hpp> 17 #include <boost/container/map.hpp> 18 #include <boost/container/string.hpp> 19 20 using namespace boost::container; 21 22 struct data 23 { 24 int i_; 25 //A vector holding still undefined class 'data' 26 vector<data> v_; 27 vector<data>::iterator vi_; 28 //A stable_vector holding still undefined class 'data' 29 stable_vector<data> sv_; 30 stable_vector<data>::iterator svi_; 31 //A stable_vector holding still undefined class 'data' 32 deque<data> d_; 33 deque<data>::iterator di_; 34 //A list holding still undefined 'data' 35 list<data> l_; 36 list<data>::iterator li_; 37 //A map holding still undefined 'data' 38 map<data, data> m_; 39 map<data, data>::iterator mi_; 40 operator <(const data & l,const data & r)41 friend bool operator <(const data &l, const data &r) 42 { return l.i_ < r.i_; } 43 }; 44 45 struct tree_node 46 { 47 string name; 48 string value; 49 50 //children nodes of this node 51 list<tree_node> children_; 52 list<tree_node>::iterator selected_child_; 53 }; 54 55 56 main()57int main() 58 { 59 //a container holding a recursive data type 60 stable_vector<data> sv; 61 sv.resize(100); 62 63 //Let's build a tree based in 64 //a recursive data type 65 tree_node root; 66 root.name = "root"; 67 root.value = "root_value"; 68 root.children_.resize(7); 69 root.selected_child_ = root.children_.begin(); 70 return 0; 71 } 72 //] 73 #include <boost/container/detail/config_end.hpp> 74