473,322 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Exceeding container::max_size()?

I was unable to locate the answer to this question in the (draft)
Standard or in The C++ Standard Library (Josuttis). What should occur
when one attempts to increase the size of a container beyond its max_size()?

The closest thing I found to an answer was that the reserve() member of
std::basic_string and std::vector and the resize() member of
std::basic_string throw std::length_error if the new size exceeds
max_size(). This seems likely to apply to all "growing" operations of
all containers, and is consistent with the description of
std::length_error, but I can't find anything that explicitly states this.

Thanks.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #1
2 981
"Kevin Goodsell" <us*********************@neverbox.com> wrote...
I was unable to locate the answer to this question in the (draft)
Standard or in The C++ Standard Library (Josuttis). What should occur
when one attempts to increase the size of a container beyond its max_size()?

AFAIUI, 'max_size' is not a requirement but rather a statement of fact.
You should never be able to create a container of that size -- you will
most likely run out of memory first.
The closest thing I found to an answer was that the reserve() member of
std::basic_string and std::vector and the resize() member of
std::basic_string throw std::length_error if the new size exceeds
max_size(). This seems likely to apply to all "growing" operations of
all containers, and is consistent with the description of
std::length_error, but I can't find anything that explicitly states this.


23.2.4.2/4 for 'std::vector'. 21.3.3/6 for 'std::basic_string'.

V
Jul 22 '05 #2
"Kevin Goodsell" <us*********************@neverbox.com> wrote...
I was unable to locate the answer to this question in the (draft)
Standard or in The C++ Standard Library (Josuttis). What should occur
when one attempts to increase the size of a container beyond its max_size()?

AFAIUI, 'max_size' is not a requirement but rather a statement of fact.
You should never be able to create a container of that size -- you will
most likely run out of memory first.
The closest thing I found to an answer was that the reserve() member of
std::basic_string and std::vector and the resize() member of
std::basic_string throw std::length_error if the new size exceeds
max_size(). This seems likely to apply to all "growing" operations of
all containers, and is consistent with the description of
std::length_error, but I can't find anything that explicitly states this.


23.2.4.2/4 for 'std::vector'. 21.3.3/6 for 'std::basic_string'.

V
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Kevin Goodsell | last post by:
I was unable to locate the answer to this question in the (draft) Standard or in The C++ Standard Library (Josuttis). What should occur when one attempts to increase the size of a container beyond...
13
by: Ioannis Vranos | last post by:
If we want our programs to be protected against buffer overflows, must we check the size of the various containers explicitly? E.g. #include <iostream> #include <string> int main()
7
by: Pat | last post by:
I want to store objects into a C++ container (e.g. vector<object>, deque<object>). Could someone help me the following questions. 1. Does there exist any size limit in the C++ container. For...
7
by: William Payne | last post by:
Hello, have you seen a recent files menu in a GUI application? In many GUI applications there's a menu the displays the most recent files that has been opened by the program. Say such a menu has...
822
by: Turamnvia Suouriviaskimatta | last post by:
I 'm following various posting in "comp.lang.ada, comp.lang.c++ , comp.realtime, comp.software-eng" groups regarding selection of a programming language of C, C++ or Ada for safety critical...
4
by: Mark P | last post by:
In my code I use something like: typedef std::list<Edge*,g_mm_Alloc<Edge*> > EdgeList; and then instantiate some EdgeList objects. Here Edge is a previously defined class and g_mm_Alloc<T> is...
16
by: Frederick Gotham | last post by:
Inspired by page 219 of Nicolai M. Josuttis's book, I set out to write a class for an intrinsic array which would behave, to as far an extent as possible, like a container. Also though, I wanted no...
10
by: arnaudk | last post by:
Hello, I am relatively new to C++ and have been milling over a container related problem for a while now. I have a ~2Gb ASCII file of time-ordered data with 4 comma-separated columns. The first...
4
by: t | last post by:
I understand size() and capacity(), but not max_size(). Lippman: c.max_size() returns maximum number of elements c can contain, where c is a container. This may be stupid, but I don't...
6
by: Peng Yu | last post by:
Hi, I'm wondering if the following assignment is lazy copy or not? Thanks, Peng std::vector<intv. v.push_back(1); v.push_back(2);
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.