Limited member function templates?
Christopher Wright
dhasenan at gmail.com
Sat Nov 10 06:11:37 PST 2007
Janice Caron wrote:
> On 11/10/07, Janice Caron <caron800 at googlemail.com> wrote:
>> On 11/10/07, Bill Baxter <dnewsgroup at billbaxter.com> wrote:
>>> The only thing you can't have is _virtual_ member function templates.
>>> Is making them virtual what you are talking about?
>> All member functions in D are virtual (unless you explicitly use the
>> "final" keyword). So obviously, yes.
>
> When we get the common calling convention whereby f(x) and x.f() are
> interchangable, then adding non-polymorphic template functions will be
> a piece of cake.
>
> Just declare as f(T)(X x, T t) { ... } and call as x.f(t).
>
> Maybe that will be enough. But yeah - I intended to mean "normal"
> functions. Polymorphic. Virtual.
I was just about to feature-request virtual templated member functions.
I can't mock them, which is one of two major problems in my mocks
library. You also can't have a templated method in an interface:
interface Collection (T) {
void addAll(U : T) (Collection!(U) toAdd); // fail
}
Which leads to annoyances: "why can't I add all my Bicycles to my
Vehicles collection?"
More information about the Digitalmars-d
mailing list