help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++ / multiple instances / iostreams


From: Detlef Vollmann
Subject: Re: C++ / multiple instances / iostreams
Date: Mon, 26 Jul 2004 22:21:05 +0200

Hans Aberg wrote:
> I might then change back and use the std::deque (or std::stack which uses
> the deque) as default for the Bison parser stack then.
std::stack probably doesn't provide the interface that's
required for a parser stack: you can always only access
the top element of the stack.
That's why I used deque.

> >> >23.2.4p1 requires "The elements of a vector are stored contiguously",
> >> >this effectively requires reallocation if the vector needs to grow.
> >>
> >> My copy of the standard does not say that. In fact, I could not find the
> >> word contiguous in the containers section.
> >Though a vector was always meant to be contiguous, it was forgotten
> >in the original text.  This is the theme of one of the earliest
> >defect reports
> > http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#69
> >It's part of the Technical Corrigendum (TC1), and therefore
> >part of the second edition ISO/IEC 14882:2003(E), sometimes
> >called C++03.
> 
> I guess that they have their reasons for this, even though it seems to be a
> wholly unnecessary thing, in view of the automated interfaces one can build
> in C++ (which are difficult to do in C).
I think it's an important thing: the standard requires three
different implementations for dynamic sequential containers,
 - a contiguous piece of memory (vector)
 - single elements linked together (list)
 - larger chunks of memory, transparently linked together (deque)
While vector and list arguably name more or less their
implementation, deque names essentially the interface, which
is IMHO a bit unfortunate.

As you wrote, it's easy in C++ to put any interface on top of
those implementation, but it's important that every C++
implementation provides those basic implementation facilities.

Detlef

-- 
Detlef Vollmann   vollmann engineering gmbh
Linux and C++ for Embedded Systems    http://www.vollmann.ch/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]