-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
It's usually the case that one would want sum types so that invalid states are unrepresentable. However:
import sumtype;
import std.stdio;
alias TheSum = SumType!(string, int);
auto s = TheSum();
s.match!((string s) => writeln("string"), (int i) => writeln("int"))This will print "string". As I see it the options are:
- Throw an exception if not initialised
assert(false)if not initialised- Decide between the current behaviour and throwing via a policy template parameter
- Add a
@disable this();toSumType
What do you think?
std.variant.Algebraic throws a VariantException for the code above.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels