Compile time checks and alias this
Andrea Fontana
nospam at example.com
Tue Dec 17 08:50:17 PST 2013
I have something like this:
enum isValid(T) = is(T == MyClass1);
class MyClass1 {}
class MyContainer(T)
{
T value;
alias value this;
}
void main()
{
assert(isValid!MyClass1, "MyClass1 isn't valid");
assert(isValid!(MyContainer!MyClass1), "MyContainer!MyClass1
isn't valid");
}
second assert conditions is false. But in normal code
MyContainer!Myclass1 is casted automagically to MyClass1 and
works almost as MyClass1.
Is there a way to check this at compile time?
More information about the Digitalmars-d-learn
mailing list