Hi, All
I'm wondering how to handle the memory allocation exception. For example,
int blocksize = 1000000;
ublas::vector<double> myvector(0);
myvector.resize(blocksize);
If the system does not have enough memory, an exception will be triggered by
the last line of the codes. I tried the try/catch as follows
try
{
myvector.resize(blocksize);
if (blocksize != myvector.size())
throw "Memory allocation failure!";
}
catch(char* str)
{
std::cout << str << std::endl;
}
However, I can do this in a much simpler way like:
myvector.resize(blocksize);
if (blocksize != myvector.size())
std::cout << "Memory allocation failure!" << std::endl;
What's the difference between these two methods? And does UBLAS have a better
built-in solution for this?
Thanks very much,
H.M.
_______________________________________________
ublas mailing list
ublas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/ublas