Re: vector : reserve(LONG_MAX)
From: Pete Becker (petebecker_at_acm.org)
Date: 04/22/04
- Next message: Julie: "Re: How to return a string of arbitrary length to caller?"
- Previous message: Karl Heinz Buchegger: "Re: Visual C++ Toolkit - .dsw compile?"
- In reply to: Alex Vinokur: "vector : reserve(LONG_MAX)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 22 Apr 2004 10:33:15 -0400
Alex Vinokur wrote:
>
> Method vector.reserve() returns no value.
> How can we prevent the following situation?
>
> ====== foo.cpp ======
> #include <climits>
> #include <vector>
> #include <iostream>
> using namespace std;
>
> int main()
> {
> vector<int> v (100e);
> cout << v.capacity() << endl;
> v.reserve(LONG_MAX);
> cout << v.capacity() << endl;
> return 0;
> }
> =====================
>
> ====== Compilation & Run ======
>
> $ g++ -v
> [---omitted---]
> gcc version 3.3.1 (cygming special)
>
> $ g++ -W -Wall foo.cpp
>
> $ a
> 100
> Aborted (core dumped)
>
> ===============================
>
Catch the exception.
-- Pete Becker Dinkumware, Ltd. (http://www.dinkumware.com)
- Next message: Julie: "Re: How to return a string of arbitrary length to caller?"
- Previous message: Karl Heinz Buchegger: "Re: Visual C++ Toolkit - .dsw compile?"
- In reply to: Alex Vinokur: "vector : reserve(LONG_MAX)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|