Get the type that a mixin is mixing into

Mike none at none.com
Mon Mar 17 06:04:34 PDT 2014


Hello,

Consider the following silly, but illustrative example:
***********************************************
mixin template HasValue(ContainingType)
{
     uint value = ContainingType.outerValue;
}

struct MyStruct
{
     uint outerValue;

     mixin HasValue!(typeof(this));
}
***********************************************


Now what if I wanted to use that mixin in a module:
***********************************************
module myModule;

uint outerValue;

mixin HasValue!(typeof({what?});   //how do I refer to the module 
type
                                      there is no 'this' for 
modules
************************************************

Basic question:  How can I have my mixin refer to the type it's 
mixing into, and have it work regardless of whether it's mixing 
into a module or a class/struct?

Thanks for the help,
Mike


More information about the Digitalmars-d-learn mailing list