On Tuesday, 29 September 2015 at 07:50:42 UTC, rumbu wrote:
Having a template:
struct SomeStruct(int size)
{
}
Is there any language trait returning the value of size
template parameter for the template instantiation SomeStruct!10?
This should do it (untested):
template SomeStructSize(T)
{
static if(is(T == SomeStruct!n, n))
enum SomeStructSize = n;
else static assert(false, T.stringof ~ " is not an instance
of SomeStruct");
}
Welcome to the weird and wonderful work of
http://dlang.org/expression.html#IsExpression