Andrei Alexandrescu Wrote:

> Currently new is baroque to the extreme. Should we eliminate the 
> class-specific allocators in favor of a simple scheme for placement new? 
> All that's really needed is to construct an object of a given type at a 
> given address. All of the syntactic mess around it is unnecessary.
> 
> I think class-specific new and delete are not a useful feature.
> 
> Second, the whole new anonymous class thing is for Java's sake. Do you 
> think we need to keep all that?
> 
> I suggest the following syntaxes for a type T, an integral length, an 
> initializerlist a la "e1, e2, e3, ..." that could be empty, and an addr 
> convertible to void*:
> 
> new T[length]
> new T(initializerlist)
> new(addr) T[length]
> new(addr) T(initializerlist)
> 
> and call it a day.
> 
> What do you think?

Yes, please :-)  That custom allocators are currently needed for placement new 
just stinks.  I agree with your assessment of custom allocators being 
problematic as well, though an alternative would be to continue allowing them 
as long as they accepted at least one argument (and the argument isn't size_t 
or whatever to avoid colliding with placement new).  This would at least make 
custom allocator use obvious at the point of instantiation, which is how 
placement new works as well.

Reply via email to