P
puzzlecracker
Item 30 page 115:
template <size_t S>
class FixedAllocator
{
public:
void* Allocate (/*requested size is always S*/);
void Deallocate (void *);
private:
/*implemented using statics*/
};
"... Because the private details are likely to use statics,however,
there could be problems if Deallocate is ever called from a static
object's destructor. Probably safer is a singleton that manages a
sepearate free list..."
First of all how is it possible to ahave a static object?
Why would there be a problem, where (could someone please provide an
example)?
Thanks.
template <size_t S>
class FixedAllocator
{
public:
void* Allocate (/*requested size is always S*/);
void Deallocate (void *);
private:
/*implemented using statics*/
};
"... Because the private details are likely to use statics,however,
there could be problems if Deallocate is ever called from a static
object's destructor. Probably safer is a singleton that manages a
sepearate free list..."
First of all how is it possible to ahave a static object?
Why would there be a problem, where (could someone please provide an
example)?
Thanks.