From 44d326e15991067003109333eb170f14ac1847a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Mon, 22 Sep 2014 22:45:55 +0200 Subject: [PATCH] Added explicit guarantee for iterators to containers of incomplete types. Added iterators to the recursive container example. --- doc/container.qbk | 4 ++++ example/doc_recursive_containers.cpp | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/container.qbk b/doc/container.qbk index 0a4bfc6..be85294 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -162,6 +162,9 @@ it statically allocates memory for `value_type` and this requires complete types [classref boost::container::basic_string basic_string] implements Small String Optimization which also requires complete types. +[*Boost.Container] containers supporting incomplete types also support instantiating iterators to +those incomplete elements. + [section:recursive_containers Recursive containers] Most [*Boost.Container] containers can be used to define recursive containers: @@ -1059,6 +1062,7 @@ use [*Boost.Container]? There are several reasons for that: * Added support for `initializer_list`. Contributed by Robert Matusewicz. * Fixed bugs: * [@https://svn.boost.org/trac/boost/ticket/10263 Trac #10263 (['"AIX 6.1 bug with sched_yield() function out of scope"])]. + * [@https://github.com/boostorg/container/pull/16 GitHub #16: ['Fix iterators of incomplete type containers]]. Thanks to Mikael Persson. [endsect] diff --git a/example/doc_recursive_containers.cpp b/example/doc_recursive_containers.cpp index 8e6c33f..6a1746a 100644 --- a/example/doc_recursive_containers.cpp +++ b/example/doc_recursive_containers.cpp @@ -24,14 +24,19 @@ struct data int i_; //A vector holding still undefined class 'data' vector v_; + vector::iterator vi_; //A stable_vector holding still undefined class 'data' stable_vector sv_; + stable_vector::iterator svi_; //A stable_vector holding still undefined class 'data' deque d_; + deque::iterator di_; //A list holding still undefined 'data' list l_; + list::iterator li_; //A map holding still undefined 'data' map m_; + map::iterator mi_; friend bool operator <(const data &l, const data &r) { return l.i_ < r.i_; } @@ -43,7 +48,8 @@ struct tree_node string value; //children nodes of this node - list children_; + list children_; + list::iterator selected_child_; }; @@ -60,6 +66,7 @@ int main() root.name = "root"; root.value = "root_value"; root.children_.resize(7); + root.selected_child_ = root.children_.begin(); return 0; } //]