El 21/09/2014 23:19, Mikael Persson escribió:
I cannot stress enough how important it is for data structure designs to be able to instantiate the iterators of containers of incomplete value types! And, in general, there is no inherent reason why, in general, incomplete type support could not extend to iterators as well. This is even more true in light of the SCARY iterator requirements (which boost containers purport to support, which cannot possibly be true given the compilation errors I have seen).
So, my main question is this: Is the following code supposed to work when using Boost.Containers?
boost::container::some_container<IncompleteType>::iterator it;
There was no requirement for that. Only for the container itself.
The documentation only states that "all Boost.Containers containers [..] are designed to support incomplete types". This needs to be clarified when it comes to iterators, at least.
Sure.
If the above code is not guaranteed to work, then may I request that it be added to the requirements? Because in my view, not having iterator support for incomplete types sort of defeats the whole purpose of supporting incomplete types, except for the most trivial use-cases (like those "recursive containers" examples). And moreover, without this support, workarounds are so major that they won't benefit from the container's support for incomplete types any more (and therefore, might as well use the standard ones instead).
I didn't have that need in the past, I used containers of incomplete to define recursive containers or like PIMPL-like idiom. If defining iterator type is desired, I see no problem in supporting that. The standard proposal: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2014/n3890.html does not mention iterators.
From experience, I know that most Boost.Container containers had working iterators for incomplete value types up to and including version 1.54 (and it's a kind of natural consequence of supporting incomplete types for the container itself). But recently, changes to the boost::container::list class have made it impossible to use of boost::container::list iterators for incomplete types (due to some convoluted new iterator scheme that I can barely understand myself). If iterators are supposed to be included in the incomplete type support, then this is a bug in the list container (and btw, boost::unordered_set also has the same problem), and I would also recommend adding this to the container unit-tests.
I've seen your pull request, thanks. I will review it and try to add support for iterators to incomplete types. And yes, containers of incomplete types (including iterators) should be better tested in the unit-tests. Best, Ion