#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Budapest
    Posts
    5
    Rep Power
    0

    STL vector and continuous memory :confused:


    as far as I understand (from B. Strousrup's book) - std::vector can resize itsefl in the same manner as if one would use the C standard lib. function realloc() on C array allocated on the heap.

    is it safe to assume STL vector allocates and re-allocates its elements continuously in memory so that there is no gaps between them?

    thanks in advance !
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    10
    Rep Power
    0
    Yes, the vector is guaranteed to store its elements in a contiguous block of memory, like a regular C-language array. string and deque also have this guarantee.

    You can read more about it in Scott Meyers' excellent book, "Effective STL."

IMN logo majestic logo threadwatch logo seochat tools logo