boostorg / container

STL-like containers from Boost
http://www.boost.org/libs/container/
Boost Software License 1.0
101 stars 113 forks source link

Fix iterators of incomplete type containers #16

Closed mikael-s-persson closed 9 years ago

mikael-s-persson commented 9 years ago

Issue: The implementation of SCARY iterators from version 1.54 to 1.55 broke the ability to use iterators of containers of incomplete types. This was simply an unfortunate consequence of a slight short-cut taken in the SCARY iterator implementation. By invoking "it_value_type::value_type", where it_value_type is the "raw" value type of iterators, typically list_node, slist_node or tree_node, the compiler is required to instantiate these node class templates in order to retrieve the dependent type "value_type", and thus, it causes a compilation error when the actual value-type of the container is an incomplete type (making the node types incomplete as well).

Fix: I did not manage to truly understand the ramifications of the iterator implementation under the hood. However, I came up with a very simple fix which replaces the it_value_type::value_type invocation by a simple meta-function iiterator_node_value_type, which is specialized for each node type (list_node, slist_node and tree_node). By adding iterators to the recursive container tests, it shows that it works (and it also works in other code that I have which requires this feature, which is why I wrote this fix!). Having iterators in those unit-tests should prevent future modifications from breaking this feature again.

To Do:

Commit: Fixes a small issue that prevented the use of iterators of containers of incomplete types. Added iterators of incomp-types to unit-tests.