Difficulties with std.variant.Algebraic
bearophile
bearophileHUGS at lycos.com
Thu Jul 11 09:47:59 PDT 2013
Meta:
> Nullable will work in this case, but it doesn't solve the
> general problem with Algebraic.
Then is this an acceptable solution?
import std.variant;
struct None {}
template Option(T) {
alias Option = Algebraic!(T, None);
}
Option!int unreliable(int val) pure nothrow {
if (val == 0) {
return typeof(return)(None());
} else {
return typeof(return)(val);
}
}
void main() {}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list