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 7087035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:37:27+00:00 2026-05-28T07:37:27+00:00

i read in other answers that theres no limit imposed by c++ compiler maximum

  • 0

i read in other answers that theres no limit imposed by c++ compiler maximum size of std::vector. i am trying to use vector for one purpose, and in need to have 10^19 items.

typedef struct{
  unsigned long price, weight;
}product;


//inside main
unsigned long long n = 930033404565174954;
vector<product> psorted(n);

the program breaks on the last statement. if i try resize(n) instead of initializing with n then also program breaks with message :

vector<T> too long
std::length_error at memory location

i need to sort the data accourding to price after putting in vector. what should i do ?

  • 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-28T07:37:27+00:00Added an answer on May 28, 2026 at 7:37 am

    std::vector does have limits on how much stuff it can carry. You can query this with std::vector::max_size, which returns the maximum size you can use.

    10^19 items.

    Do you have 10^19 * sizeof(product) memory? I’m guessing that you don’t have ~138 Exabytes of RAM. Plus, you’d have to be compiling in 64-bit mode to even consider allocating that much. The compiler isn’t breaking; your execution is breaking for trying to allocate too much stuff.

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

Sidebar

Related Questions

I have read other questions on this topic but none that actually answers my
I've read the lame documentation, and checked other answers. I'd like my Android app
I've read the questions/answers explaining that there is no multiple inheritance in C# ,
I read other questions about subject. I know what I should not rely on.
If you read other people's source code, how do you approach the code? What
I have read other related question but i cant really get them to relate
my jQuery.ajax return JSon object. I firstly read other articles. but their response text
I have read the other posts, e.g., vim: Executing a list of editor commands
I've read several other questions about material in order to learn RoR. But my
I've read through other questions but to no avail - I really can't work

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.