"This for <member> needs to be type <class>, not type <otherclass>"
Jarrett Billingsley
kb3ctd2 at yahoo.com
Fri May 2 10:23:22 PDT 2008
"Simen Kjaeraas" <simen.kjaras at gmail.com> wrote in message
news:fvfg2g$1nnp$1 at digitalmars.com...
> While playing around with templates and alias parameters, I got the die of
> trying this:
>
> struct foo(alias T)
> {
> typeof(T) opAddAssign(typeof(T) rhs)
> {
> return T += rhs;
> }
> }
If you make this a template:
template foo(alias T)
// rest is the same
>
> class bar
> {
> private:
> int _baz;
> public:
> foo!(_baz) baz;
And now change this to a mixin:
mixin foo!(_baz) baz;
It works.
Of course, this has the effect of making foo (or rather an instance of foo)
no longer a type. But maybe you don't need it to be.
More information about the Digitalmars-d-learn
mailing list