How to create mixin template and pass name of a variable?
Bosak
bosak at gmail.com
Fri Aug 2 04:37:26 PDT 2013
I want to create a mixin template such that:
mixin template ArgNull(alias arg, string name)
{
if(arg is null)
throw new Exception(name~" cannot be null.");
}
But is there a way to do that with only one template argument.
And then use it like:
string text = null;
mixin ArgNull!(text);
And the above mixin to make:
if(text is null)
throw new Exception("text cannot be null.");
More information about the Digitalmars-d-learn
mailing list