Container templates

Meta jared771 at gmail.com
Fri Feb 21 19:24:39 PST 2014


On Thursday, 20 February 2014 at 18:55:06 UTC, Frustrated wrote:
> This should work. Just have to add the overrides and call the
> base function(e.g., "override" insert and then call x's insert).
>
> This at least gets the job done... I wonder if there is a better
> way?

If you want a.Add() (insert() in the case of std.container.Array) 
to work correctly and be overloaded for both ints and floats, I 
don't think you have any choice beside implementing it yourself. 
This is exactly the kind of problem that multiple alias this 
could solve, but that's not implemented, so I guess you're out of 
luck. Like you said earlier, however, you can just create a 
template mixin that mixes in the Array functionality for any type 
you want, which is about as succint as you're going to get.


More information about the Digitalmars-d-learn mailing list