use an auto_ptr to remove an explicit try/catch in the cache

This commit is contained in:
Joe Thornber 2011-11-08 10:38:52 +00:00
parent 6dc6110684
commit 8859451df5

17
cache.h
View File

@ -8,6 +8,7 @@
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <list> #include <list>
#include <map> #include <map>
#include <memory>
#include <stdexcept> #include <stdexcept>
//---------------------------------------------------------------- //----------------------------------------------------------------
@ -182,17 +183,11 @@ namespace base {
cache<ValueTraits>::insert(value_type const &v) { cache<ValueTraits>::insert(value_type const &v) {
make_space(); make_space();
// FIXME: use an auto_ptr to avoid the explicit try/catch std::auto_ptr<value_entry> node(new value_entry(v));
value_entry *node = new value_entry(v); value_ptr_cmp cmp;
try { lookup_algo::insert_equal(&lookup_header_, &lookup_header_, node.get(), cmp);
value_ptr_cmp cmp; node.release();
lookup_algo::insert_equal(&lookup_header_, &lookup_header_, node, cmp); current_entries_++;
current_entries_++;
} catch (...) {
delete node;
throw;
}
} }
template <typename ValueTraits> template <typename ValueTraits>