Re: [C++] Vectors & Dynamic allocation
From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: 04/30/04
- Next message: SaltPeter: "Re: C++ array declaration question"
- Previous message: B. v Ingen Schenau: "Re: long veriable causes problem"
- In reply to: Robert W Hand: "Re: [C++] Vectors & Dynamic allocation"
- Next in thread: Mark : "Re: [C++] Vectors & Dynamic allocation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 30 Apr 2004 10:35:48 +0100
In message <bm44909io91ceu7kt4kjhforg3nmvjp8m8@4ax.com>, Robert W Hand
<rwhand@NOSPAMoperamail.com> writes
>In the section of the Standard devoted to std::vector<T>::erase, there
>is a paragraph labeled "Complexity". It states that the destructor of
>T is called the number of times equal to the number of elements
>erased,
Indeed it says that, but I do not know why because erase() for vectors
does not remove elements, you have to use std::remove() to do that. All
erase does is to write new values into the erased elements (using copy
assignment).
> but the assignment operator for T is called the number of
>times equal to the number of elements after the erased elements.
>There is no provision for deallocation. Furthermore, since iterators
>before the erasure remain valid, an allocation/deallocation step seems
>impossible. Deallocation/allocation would invalidate all the
>iterators.
And I do not know why it mentions invalidation of iterators as it seems
to me that the iterators remain valid but the values of the objects they
identify changes.
-- Francis Glassborow ACCU Author of 'You Can Do It!' see http://www.spellen.org/youcandoit For project ideas and contributions: http://www.spellen.org/youcandoit/projects
- Next message: SaltPeter: "Re: C++ array declaration question"
- Previous message: B. v Ingen Schenau: "Re: long veriable causes problem"
- In reply to: Robert W Hand: "Re: [C++] Vectors & Dynamic allocation"
- Next in thread: Mark : "Re: [C++] Vectors & Dynamic allocation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|