Added explicit guarantee for iterators to containers of incomplete types. Added iterators to the recursive container example.

This commit is contained in:
Ion Gaztañaga
2014-09-22 22:45:55 +02:00
parent f5e678fc70
commit 44d326e159
2 changed files with 12 additions and 1 deletions

View File

@@ -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]

View File

@@ -24,14 +24,19 @@ struct data
int i_;
//A vector holding still undefined class 'data'
vector<data> v_;
vector<data>::iterator vi_;
//A stable_vector holding still undefined class 'data'
stable_vector<data> sv_;
stable_vector<data>::iterator svi_;
//A stable_vector holding still undefined class 'data'
deque<data> d_;
deque<data>::iterator di_;
//A list holding still undefined 'data'
list<data> l_;
list<data>::iterator li_;
//A map holding still undefined 'data'
map<data, data> m_;
map<data, data>::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<tree_node> children_;
list<tree_node> children_;
list<tree_node>::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;
}
//]