class allocators should be more encapsulated
    Luís Marques 
    luismarques at gmail.com
       
    Fri Dec 29 06:24:03 PST 2006
    
    
  
Frits van Bommel wrote:
> Yes they do take parameters, and the reason is indeed to customize how 
> memory is allocated. But unless they throw an exception, they do have to 
> actually _allocate_ some memory. If they don't throw, the return value 
> must be a void* to a newly-allocated piece of memory.
> So what I gather you're trying to do (potentially return a pointer to an 
> already-existing object) isn't acceptable behavior for a custom allocator.
You are right. If I return an existing object it will be initialized to 
default values. I guess that means the solution to a singleton pattern 
proposed by Burton Radons does not work 
(http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=D&artnum=14520)
Still, it's a pity that "new ClassType()" cannot be used to 
transparently return an existing object (conditionally or not).
--
Luís Marques
    
    
More information about the Digitalmars-d
mailing list