Re: Accessing vector content even though size = 0
In message <fpe69t$qmr$1@news.net.uni-c.dk>, Hansen
<bluesboys@remove.the.spam.hotmail.com> writes
Hi group,
I'm writting a test at the moment where I want to inspect the content of a
vector that I uses as a buffer. The problem is that the function which
populates the vector also sends the vector and the send method performs a
resize(0).
Start with the real problem. *Why* does a function called "send"
actually perform "clear"?
So when I try to inspect the vector afterwards, it appears empty.
It _is_ empty, by any standard-conforming interpretation.
I there a way to get a pointer to the beginning of the vector, since the
data is still there.
For some definition of "still there" involving the words "undefined
behaviour", maybe.
Or is it possible to perform a resize(n) that doens't
zero out the content?
No.
I now that the _Myfirst member of vector points to the beginning of the
vector, but thats a protected member and hence inaccessible.
Because it's an implementation detail.
Any ideas?
Solve the real problem, which is in the algorithm, not the low-level
details.
(I've tried using the #define protected public hack,
UB.
but since the code
being tested is located in another compilation unit, I get a dllimport
error, since some of the methods being used are defined as protected)
--
Richard Herring