
I have recently converted my code to CRTP form and noticed an inherent problem with creating an allocator template now. Because the derived class is the final singleton class, and its ctor and dtor are protected, there is no way to give a generic allocator the right to create the object. Allocator just allocates N bytes, object creates itself via
"Jason Hise" wrote: placement new. static T * Create ( ) { void * p = Allocator::allocate(sizeof(T)); try { return new (p) T(...); } catch ( ... ) { Allocator::deallocate(p); throw; } } Instead of try/catch shared_array should be used to avoid destroying stack frame when exception throws. /Pavel