abstract function templates

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun Dec 26 15:59:32 PST 2010


On 12/27/10, Simen kjaeraas <simen.kjaras at gmail.com> wrote:
>
> Yes indeed. This was what I meant by saying that template functions
> cannot be virtual. D sadly has no way to create templated functions
> that work in a class hierarchy. :(
>

Does it really make sense for a class to have methods that accept any
type of argument? It's one thing to have a class specialized on some
type(s), e.g.:

class Foo(T1, T2)
{
    void bar(T1 var, T2 etc) { }
}

But having a class method which can accept any type, that seems odd to
me. I don't know since I've never used such a thing before, but maybe
it has some good use cases? (I'd love to know about those btw!). You
can introduce constraints, but I thought having parameterized classes
would solve most of the use-case scenarios.


More information about the Digitalmars-d-learn mailing list