TemplateOf behavior

Alex sascha.orlov at gmail.com
Sat Jan 6 19:58:10 UTC 2018


//code starts

import std.traits;

void main()
{
	static assert(__traits(isSame, TemplateOf!(T!arr), T));
}

size_t[] arr;

struct T(alias S)
{
	mixin Contents!() contents;

	this(Args)(ref Args args)
	{
		contents.__ctor(42);
	}
}

static assert(__traits(isSame, TemplateOf!(T!arr), T));

mixin template Contents()
{
	int dummy;
	this(int dummy)
	{
		//static assert(__traits(isSame, TemplateOf!(T!arr), T));
	}
}

//code ends

Given the code above, why the static assert inside the mixing 
template constructor yields false, while the others yield true?


More information about the Digitalmars-d-learn mailing list