Axel wrote:
how can I reserve enough memory for a long string? I tried with
max_size() but 4GB is to much for my system, an exception ist the
result. And I'm getting an exception too when using the normal string
and putting to much in it.
If I want to initialise a std::string using 20MB of memory, how can I do
this?
i think what you want is std::string::reserve().
Per the SGI STL docs, reserve() does:
Requests that the string's capacity be changed; the postcondition for this
member function is that, after it is called, capacity() >= n. You may
request that a string decrease its capacity by calling reserve() with an
argument less than the current capacity. (If you call reserve() with an
argument less than the string's size, however, the capacity will only be
reduced to size(). A string's size can never be greater than its capacity.)
reserve() throws length_error if n > max_size().
--
----- stephan beal
Registered Linux User #71917
http://counter.li.org
I speak for myself, not my employer. Contents may
be hot. Slippery when wet. Reading disclaimers makes
you go blind. Writing them is worse. You have been Warned.