Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:18:27+00:00 2026-05-25T10:18:27+00:00

C++ textbooks, and threads, like these say that vector elements are physically contiguous in

  • 0

C++ textbooks, and threads, like these say that vector elements are physically contiguous in memory.

But when we do operations like v.push_back(3.14) I would assume the STL is using the new operator to get more memory to store the new element 3.14 just introduced into the vector.

Now say the vector of size 4 is stored in computer memory cells labelled 0x7, 0x8, 0x9, 0xA. If cell 0xB contains some other unrelated data, how will 3.14 go into this cell? Does that mean cell 0xB will be copied somewhere else, erased to make room for 3.14?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:18:27+00:00Added an answer on May 25, 2026 at 10:18 am

    std::vector first allocates a bigger buffer, then copies existing elements from the “old” buffer to the “new” buffer, then it deletes the “old buffer”, and finally adds the new element into the “new” buffer.

    Generally, std::vector implementation grow their internal buffer by doubling the capacity each time it’s necessary to allocate a bigger buffer.

    As Chris mentioned, every time the buffer grows, all existing iterators are invalidated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have textboxes, dropdownlists and submit buttons. They are all inline-elements. Which means
I would like several textboxes to react to changes of an underlying string. So
This is for homework but please know that I have looked online for help
I have a variety of textbooks that note that there wasn't a hash container
The are several sorting algorithms like inserstion sort, selection sort, bubble sort etc. that
Do you know how to access textboxes added to a radgrid that are not
I have a UserControl that consists of three TextBoxes. On a form I can
This is basically implementing search/find in a WPF window or User control. Let's say
We have a Java web application and we'd like to set up some basic
I wrote little WPF application with 2 threads - main thread is GUI thread

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.