On Tue, Jun 29, 2010 at 10:42:36AM -0400, Richard Heck wrote:
> 
> >Thanks for the pointers.  Sorry for not providing more context about
> >what I am trying to accomplish.  The addition of a vector into the
> >TocItem class was to give me a place to store other insets that might
> >also be present in the paragraph.
> >
> ><<  I think he really does mean: vector<TocItem>  *>>
> >
> >That's correct.  I've rewritten the InsetText class to identify Note
> >insets and add them to this vector.  It then gets unpacked to a second
> >column of the Table of Contents model and used in various custom views
> >(such as the expanded outline pane).
> >
> >I know that it looks strange, but there really is some method to the
> >madness.  I'm  not sure if it is the best method for storing and
> >retrieving this type of information, but it seems to be working pretty
> >well so far.  I should probably send along a patch that shows all of
> >these changes in context to get feedback ...
> >
> I'm still a bit puzzled, though maybe seeing the whole code would
> clear things up. [...]

Maybe we should try to shed some light on the issue.

In 
    struct Foo
    {
        std::vector<Foo> f;
    };

the type 'Foo' is "incomplete" until the definition is finished, i.e.
basically up to the location of the '}'.

std::vector<T> requires T to fulfill the "assignable" concept. I haven't
found chapter and verse but I'd bet an incomplete type is not "assignable".

Now, 17.4.3.6.2 explicitly gives the compiler implementors a choice what to
do in such situations. gcc chooses (as any other compiler I am aware of)
to do the sensible thing, namely to simply to compile the code without
further ado.

However, gcc also provides the user with a choice to select insane
behaviour, i.e. to bail out whenever the concept is not met, even if
the code could be compiled and would work fine.

That's the behaviour LyX selects unless it is configured with
--disable-concept-check .

The fact that replacing std::vector with QVector works even in the
presence of enabled concept checks is that QVector does not enforce
the concept by artificially breaking the compilation.

Using std::vector<Foo *> works because 'Foo *' is a complete type even
if Foo itself is incomplete.

Why using std::vector<Foo> * works is currently unclear to me as Foo
is as incomplete as in the direct case. Maybe we've not seen yet the
culmination of concept check frenzy and this will break later. For
now it looks like the solution with the lowest impact, though.

Andre'


Reply via email to