equivariant functions

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Wed Oct 15 05:33:38 PDT 2008


Andrei Alexandrescu wrote:
> 3. Walter's example:
> 
> class Base {}
> class Derived : Base {}
> 
> typeof(a) foo(Base a) { return new Base; }
> 
> Typecheck like this:
> 
> typedef Base __Surrogate;
> __Surrogate foo(__Surrogate a)
> {
>     return new Base;
> }
> 
> Fail, as it should.
> 
> 
> Come at it with all you've got.

What does 'return new typeof(a);' do? :)



More information about the Digitalmars-d mailing list