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: Wed, 28 Jul 2004 16:36:26 +0200

Hans Aberg wrote:
> At 22:21 +0200 2004/07/26, Detlef Vollmann wrote:
> >I think [vectors implemented as arrays is] 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.
> 
> The C++ standard is a bit schizoid, attempting to follow the original C
> standard, where the underlying implementation is not indicated, not
> shutting out various hardware architectures. Then it becomes funny when one
> imposes conditions that in effect forces a type of implementation. And not
> even C99 could anymore shun away from this path, as one, for example, now
> can indicate integral types with sizes.
I have a different opinion on that (of course ;-)
As you can see from my signature, I'm (also) in the embedded domain.
And there it is very important that you can potably define fix
integer sizes.  Potably here means portable across different
compilers, not (generally) portable across different hardware
platforms.

> There is no particular point in requiring a particular implementation, if
> there is no way one can take advantage of it. In the case of std::vector,
> one still has to use the interface, so it makes no difference how it is
> implemented.
But that's exactly the point: you can take advantage of it.
The wording for the contiguous requirement makes it clear
that you can call a legacy C function that requires a classic
C array in form of a pointer with &vec.front().

For deque it is guaranteed that references (pointers) to elements
are not invalidated on insertion.  For some systems it's also
very important that you don't reallocate (and copy) on growing:
if you have sequences larger than the avilable physical memory,
a vector typically causes trashing on growing, while a deque
that is only sequentially accessed often still performs pretty well.

And for list, you in fact have pretty different runtime complexities.

> This
> is just another place in the C++ standard where one has a wishy-washy
> attitude.
It might be that the C++ Standard is "wishy-washy" at places, but
the fact that three different implementations are required under
clearly specified names is IMHO an important and well thought through
decision of the C++ committee (apart from the naming itself).

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]