Persistent list
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Mon Nov 16 13:49:38 PST 2015
On Monday, 16 November 2015 at 21:25:52 UTC, Timon Gehr wrote:
> On 11/16/2015 10:18 PM, Jonathan M Davis wrote:
>> I don't know of any way to templatize a member function on the
>> type of
>> the this pointer/reference, but maybe there's a template
>> feature with
>> which I'm not familiar enough.
>
> Indeed there is.
>
> class C{
> void foo(this T)(){ pragma(msg, T); }
> }
>
> class D: C{}
>
> void main(){
> auto c=new const(C)();
> c.foo();
> auto d=new immutable(D)();
> d.foo();
> }
Cool. That's good to know about. Thanks.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list