|
Boost Users : |
From: Milutin Jovanovic (milutin.jovanovic_at_[hidden])
Date: 2006-08-02 13:59:35
I finally decided to switch to boost from my own implementation of some
helper classes, and I noticed that scoped_ptr and scoped_array in boost lack
the release method(). I had to fall back to std::auto_ptr.
However, this seems like such a basic and fundamental problem that I have
started to fear that I am missing something obvious... The usage I got used
to was something like this:
{
scoped_ptr<A> temp( new A() );
verify( temp.get() ); // might throw
store_in_a_very_special_place( temp.get() ); // might throw; and I
should keep ownership if thrown
temp.release();
}
I though this was good practice to make code exception safe. Sure I could do
it with try-catch but that gets messy if I allocate multiple instances etc.
So the question is:
1) is there something wrong with the concept of release()?
2) if release() is not evil, is there any other reason why is it not in
boost::scoped_*?
Regards,
Milutin Jovanovic
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net