473,396 Members | 2,099 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,396 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 1608
"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...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.