On Mon, 01 Sep 2014 10:57:41 +0000 evilrat via Digitalmars-d-learn <[email protected]> wrote:
and to check that ugly hackery:
mixin template makeAlias(string aliasName, string Name, alias
Replace) {
static if ( __traits(compiles, (mixin(Name~`.sizeof`))) )
mixin(`alias `~aliasName~` = ` ~ Name ~ `;`);
static if ( (is(Replace == class) || is(Replace == struct)) )
mixin(`alias `~aliasName~` = ` ~ Replace.stringof ~ `;`);
else static assert(0);
}
struct A {}
struct B {}
struct C {}
mixin makeAlias!("coolStruct", "MyStruct", A);
mixin makeAlias!("coolStruct1", "B", C);
void doSomething(coolStruct cs)
{
static if (!is(typeof(cs) == A)) static assert(0);
//.. do something with struct ..
}
void doSomething1(coolStruct1 cs)
{
static if (!is(typeof(cs) == B)) static assert(0);
//.. do something with struct ..
}
signature.asc
Description: PGP signature
