Hello FeepingCreature,
On 24.02.2010 05:16, BCS wrote:I need a function that works like the following:T* New(T)() { return new T; }But that also works with static arrays:auto i = New!(int)(); auto a = New!(int[27])();The cleanest solution I can think of is:T* New(T)() { return (new T[1]).ptr; }but that seems ugly. Any ideas?The example you listed is the best way.
As it happes, it dosn't work as shown: auto o = New!(Object)(); // oops, typeof(o) == Object*
I'm sorry.
-- ... <IXOYE><
