K
kwijibo28
Hi all,
I've got a simple question regarding stl containers. Consider this
code:
std::vector<float> foo;
foo.resize(100);
How do I know if memory allocation was successful? The resize method
returns nothing. I understand that resize does not always allocate
memory. But even if I use the reserve method it doesn't return boolean
or something to validate.
Should I do something like this:
if(foo.capacity()<foo.size())
cout << "Memory allocation fail!" << endl;
Is there any standard way of doing this.
Thanks all
Kwijibo
I've got a simple question regarding stl containers. Consider this
code:
std::vector<float> foo;
foo.resize(100);
How do I know if memory allocation was successful? The resize method
returns nothing. I understand that resize does not always allocate
memory. But even if I use the reserve method it doesn't return boolean
or something to validate.
Should I do something like this:
if(foo.capacity()<foo.size())
cout << "Memory allocation fail!" << endl;
Is there any standard way of doing this.
Thanks all
Kwijibo