Templated struct doesn't need the parameterized type in return type definitions?

Nick Treleaven nospam at example.net
Wed Mar 9 07:16:08 PST 2011


On Tue, 08 Mar 2011 15:25:27 -0500, Steven Schveighoffer wrote:

> "Hey, wouldn't it be cool if I could add a custom allocator to all
> classes!?"...
> 
> class Collection(T, alloc = DefaultAllocator!T) {
>     Collection!(T) add(T t) { ...; return this; } // 20 other now subtly
>     incorrect functions like add...
> }
> 
> See the problem?

This seems like a good reason to keep allowing the feature. It would be 
nice if it could be documented clearly somewhere, maybe here:

http://www.digitalmars.com/d/2.0/template.html#ClassTemplateDeclaration


More information about the Digitalmars-d-learn mailing list