Boost logo

Boost :

Subject: [boost] [containers] Clarifications on incomplete type support?
From: Mikael Persson (mikael.s.persson_at_[hidden])
Date: 2014-09-21 17:19:43


Hi all,

I've been using Boost.Containers for some time now. As for many, the
primary (and only) reason for using them (over STL ones) is that they
support incomplete value types.

Since the beginning, I have always assumed that support for incomplete
value types meant that I could instantiate the container type and any
indirect type, most notably, **iterators**.

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;

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.

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).

>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.

Thanks,
Mikael Persson


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk