Bug in container vector ??

Is vector supposed to delete an instance passed to it right a way, or is
this a bug in vector??
You see in the QNX 6.0.0 libraries this did not happen, in the 6.1.0 it
does…
When using vector in the way listed in the included files i get the
following output.

Constructor: Create Test.
Destructor: Delete Test.
Now in class test writing to cout.
This is a small test to check some vector stuff
Destructor: Delete Test.

As far as I’m concerned I should have got the following output (as is
the case with 6.0.0):

Constructor: Create Test.
Now in class test writing to cout.
This is a small test to check some vector stuff
Destructor: Delete Test.

-Arve

go ahead and read on how vector is working on the objects it includes.
the first one ist absolutly correct, if the initial capacity of the vector
element was zero.
if a vector is full and you insert a new element, vector will allocate a new
list that is big enough to the hold all the elements,
afterwards all elements are copied to the new list, and this copying is done
using the copy-constructor!
so therfore either use:
vectorObject.reserve(yourSize) // increases the capacity to the given size,
that means that no reallocation is done 'til that no. elements is reached
or:
do not use vector on objects themselves use it only on pointers, because you
will always have some overhead in object creation and destruction.
but keep in mind that in this case you will have to take care about cleaning
up the list elements on your own, but in my opinion this will only clear up
your code.


“Arve Slenes” <arve@datarespons.no> schrieb im Newsbeitrag
news:3B5FDFB0.F3FB699E@datarespons.no

Is vector supposed to delete an instance passed to it right a way, or is
this a bug in vector??
You see in the QNX 6.0.0 libraries this did not happen, in the 6.1.0 it
does…
When using vector in the way listed in the included files i get the
following output.

Constructor: Create Test.
Destructor: Delete Test.
Now in class test writing to cout.
This is a small test to check some vector stuff
Destructor: Delete Test.

As far as I’m concerned I should have got the following output (as is
the case with 6.0.0):

Constructor: Create Test.
Now in class test writing to cout.
This is a small test to check some vector stuff
Destructor: Delete Test.

-Arve

Makes sense – Thanks!

-Arve

HP Reichert wrote:

go ahead and read on how vector is working on the objects it includes.
the first one ist absolutly correct, if the initial capacity of the vector
element was zero.
if a vector is full and you insert a new element, vector will allocate a new
list that is big enough to the hold all the elements,
afterwards all elements are copied to the new list, and this copying is done
using the copy-constructor!
so therfore either use:
vectorObject.reserve(yourSize) // increases the capacity to the given size,
that means that no reallocation is done 'til that no. elements is reached
or:
do not use vector on objects themselves use it only on pointers, because you
will always have some overhead in object creation and destruction.
but keep in mind that in this case you will have to take care about cleaning
up the list elements on your own, but in my opinion this will only clear up
your code.

“Arve Slenes” <> arve@datarespons.no> > schrieb im Newsbeitrag
news:> 3B5FDFB0.F3FB699E@datarespons.no> …
Is vector supposed to delete an instance passed to it right a way, or is
this a bug in vector??
You see in the QNX 6.0.0 libraries this did not happen, in the 6.1.0 it
does…
When using vector in the way listed in the included files i get the
following output.

Constructor: Create Test.
Destructor: Delete Test.
Now in class test writing to cout.
This is a small test to check some vector stuff
Destructor: Delete Test.

As far as I’m concerned I should have got the following output (as is
the case with 6.0.0):

Constructor: Create Test.
Now in class test writing to cout.
This is a small test to check some vector stuff
Destructor: Delete Test.

-Arve