CRTP in D?

div0 div0 at users.sourceforge.net
Thu Aug 20 12:15:32 PDT 2009


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

John C wrote:
> div0 Wrote:
>> 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.
> 
> import std.typetuple;
> 
> class C(M...) {
> 
>   mixin TypeTuple!(M);
> 
> }
Unfortunately that doesn't work.

It stops the immediate compile error, but the mixin doesn't
do anything:

template a() {
  void funcA() { writefln("funcA"); }
}

template b() {
  void funcB()() { writefln("funcB"); }
}

class theClass0(M ...) {
  mixin TypeTuple!(M);
}

void test() {
  auto g = new theClass0!(a, b);
  g.funcA();
  g.funcB();
}

main.d(31): Error: no property 'funcA' for type
'main.theClass0!(a,b).theClass0'
main.d(31): Error: function expected before (), not __error of type int
main.d(32): Error: no property 'funcB' for type
'main.theClass0!(a,b).theClass0'
main.d(32): Error: function expected before (), not __error of type int
main.d(33): Error: no property '_a' for type
'main.theClass0!(a,b).theClass0'
main.d(33): Error: no property '_b' for type
'main.theClass0!(a,b).theClass0'

Same with both 1.046 & 2.031

TY though.

- --
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/

iD8DBQFKjaDUT9LetA9XoXwRAoo6AKDBMZC2Sc59UfDof1SSM5G9i9en6QCgk2DJ
1FMBI1zOfbuokGDx2M4ahDg=
=wDXk
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list