Instead of using try/catch blocks everytime I need to construct any objects after allocating a block of memory for them with an allocator I use internally in my container, I would like to use a class derived from std::auto_ptr (I have no c++11 here) with an overridden destructor, so that it could deallocate the pointed memory and release the pointer afterwards. Are there any disadvantages in doing this?
Asked
Active
Viewed 115 times
0
-
Even though you have no C++11, you probably have `shared_ptr` and `unique_ptr` nonetheless (it's C++03 actually). If you don't, you still can use the implementation in boost. – J.N. Mar 12 '12 at 11:47
-
@PawelZubrycki the allocator I use is a template parameter, which defaults to the classic std::allocator
– Martin Mar 12 '12 at 11:51