help-bison
[Top][All Lists]
Advanced

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

Re: C++ / multiple instances / iostreams


From: Hans Aberg
Subject: Re: C++ / multiple instances / iostreams
Date: Sun, 25 Jul 2004 15:15:15 +0200

At 23:28 +0200 2004/07/24, Detlef Vollmann wrote:
>> >Ah, I see.  I use std::deque, which doesn't do re-allocation on
>> >expanding but links new chunks to existing ones when growing.
>>
>> Some implementations may do so, but mine does not. (Typically, a deque just
>> uses an array chunk where the location arithmetic wraps around the edges.)
>23.2.1.3p1 explicitely requires that no references to elements
>in a deque are invalidated on an insert at the end or beginning.
>This effectively forbids reallocation.

OK. They have then added some extra conditions on the notion of a deque.

>> And, if you so want, you could do it on std::vector as well. The C++
>> standard just gives time limiting complexities, but does not explicitly say
>> what implementation to use.
>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.

But the standard prefers a deque over a vector for stack, for some reason.
I decided to use a std::vector in the Bison C++ parser, though, since there
was no apparent advantage to me by using a stack. There has been some
tricks in use in the with the C parser, relying on an underlying array, but
those are now fazed out, as a preparation for multilanguage support.

  Hans Aberg






reply via email to

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