On the richness of C++

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Apr 11 06:47:20 PDT 2008


Sean Kelly wrote:
> I'd personally like for "placement new" to be supported by the language.  I've
> considered adding a new(void*) method to Object for this purpose in Tango,
> but haven't experimented enough to find out if this would cause any problems.
[snip]
> 
>     class Object {
>         void* new( size_t s, void* p ) {
>             return p;
>         }
>     }

Might I suggest that if you ever again get the urge to add placement 
new, you consider adding
---
void* new( size_t s, void[] arr ) {
     assert(s <= arr.length);
     return arr.ptr;
}
---
instead?



More information about the Digitalmars-d mailing list