Topic: std::vector<>


Author: "Uwe Keim" <uwe.keim@imos.net>
Date: 1998/02/15
Raw View
Hello!

for calling some C-functions, often a pointer to a _contiguous_ array of
objects is needed.

e.g.
void f( int[] ai )
{
    // ...
}

std::valarray<>, as said in stroustrup (3rd ed, page 667),
_is_ contiguous in memory.

But he also says, it is intended to have a fixed size after being
initialized.


What I want is the functionality of std::vector<>, and the ability of
having access to it like a normal array, allocated with new[]
(with as few performance loss as possible).


In my STL-implementation (MS VC++, 5.0), the std::vector<>
_is_ contiguous in memory.
Can I assume that this is always the case (I don't think so)?


What do YOU do, when you need a contiguous array in memory?
(Please don't tell me, that real c++ programmers don't need this ability -
I hat it, too, but need it anyway).


Thanks for your time,
Uwe
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]