18 #ifndef OBJECT_CACHE_GUARD
19 #define OBJECT_CACHE_GUARD
65 _cacheDeleter(_cache) {
71 return auto_ptr<T>(
new T());
73 auto_ptr<T> object(_cache.back());
78 template<
class T>
template<
class S>
81 return auto_ptr<T>(
new T(copyOf));
83 auto_ptr<T> object(_cache.back());
89 template<
class T>
template<
class S>
91 ASSERT(
dynamic_cast<T*
>(
object.get()) != 0);
93 auto_ptr<T> casted(
static_cast<T*
>(
object.release()));
void noThrowPushBack(Container &container, auto_ptr< Element > pointer)
An ObjectCache keeps a cache of previously-used objects to cut down on the number of allocations.
auto_ptr< T > newObjectCopy(const S ©Of)
Returns a copy of copyOf.
auto_ptr< T > newObject()
Returns an object.
void freeObject(auto_ptr< S > object)
Insert an object into the cache.
ElementDeleter< vector< T * > > _cacheDeleter