CRTP in D?

div0 div0 at users.sourceforge.net
Wed Aug 19 13:36:37 PDT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bill Baxter wrote:
> On Wed, Aug 19, 2009 at 10:32 AM, div0<div0 at users.sourceforge.net> wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> downs wrote:
>>> bearophile wrote:
>>>> I don't know much C++. Can CRTP be used in D1 too, to improve the performance of some D1 code?
>>>>
>>>> http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern
>>>>
>>>> Bye,
>>>> bearophile
>>> We have this, except we call it "template mixin" :)
>> No, template mixins are not CRTP.
> 
> Mixins can be used to do a lot (most? all?) of things CRTP is used for:
> 
> class Class(alias MixMe)
> {
>    mixin MixMe impl;
>    ...
>    void doSomething {
>          impl.doIt();
>    }
> }
> 
While we're on the subject, is it possible to mixin in a tuple?
Doesn't seem like you can...

class C(M...) {
 mixin M;
}

Doesn't work.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFKjGJVT9LetA9XoXwRApgoAJ9hEW/qAJ5uCR+186MfH2ebDD1zIQCaA8RT
jdlbCp7Tj0oX1BMievFVXOk=
=GtuO
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list