{ Multi-posted article. -mod }
Hello,
I am using std::auto_ptr to try to keep ownership of resources
straight. However, I became aware that exception objects must provide
a copy constructor, which made me uncertain of the soundness of
throwing std::auto_ptrs...
It was explained to me that a problem is:
try {
throw std::auto_ptr<int>(new int(10));
} catch (std::auto_ptr<int> a) {
throw;
}
If I understood correctly, the re-throw would use the original
exception object, which has lost ownership.
Is there a way to prevent catching by value?
Is catching by reference kosher?
Are there other problems with throwing auto_ptrs?
Thanks.
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]