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

  • SEARCH
  • Home
  • 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 3991172
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:35:00+00:00 2026-05-20T06:35:00+00:00

Is the capacity size of string always a multiple value of 15? for example:

  • 0

Is the capacity size of string always a multiple value of 15?

for example: In all cases the capacity is 15

string s1 = "Hello";

string s2 = "Hi";

string s3 = "Hey";

or is it random?

  • 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-20T06:35:01+00:00Added an answer on May 20, 2026 at 6:35 am

    Is the capacity size of string always a multiple value of 15?

    No; the only guarantee about the capacity of a std::string is that s.capacity() >= s.size().

    A good implementation will probably grow the capacity exponentially so that it doubles in size each time a reallocation of the underlying array is required. This is required for std::vector so that push_back can have amortized constant time complexity, but there is no such requirement for std::string.

    In addition, a std::string implementation can perform small string optimizations where strings smaller than some number of characters are stored in the std::string object itself, not in a dynamically allocated array. This is useful because many strings are short and dynamic allocation can be expensive. Usually a small string optimization is performed if the number of bytes required to store the string is smaller than the number of bytes required to store the pointers into a dynamically allocated buffer.

    Whether or not your particular implementation performs small string optimizations, I don’t know.

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

Sidebar

Related Questions

Why the capacity must be a multiple or 2? Why use & in the
I am trying to select minimum and maximum value for capacity from MySQL table
In the C++ Standard Library, std::string has a public member function capacity() which returns
Certain collection types in .Net have an optional Initial Capacity constructor parameter. For example:
I need to find the underlying disk capacity (total size) of an unmapped network
I instantiate an std::vector foo(1000) . foo.size() is now 1000 and foo.capacity() is also
I'm looking to get data such as Size/Capacity, Serial No, Model No, Heads Sectors,
I know that vectors double in size whenever their capacity() is exceeded. This operation
I was reading the Maximum Capacity Specifications for SQL Server and I came across
How would you implement a capacity-limited, generic MruList in C# or Java? I want

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.