On Thursday, 9 August 2018 at 01:04:43 UTC, Paul Backus wrote:
On Thursday, 9 August 2018 at 00:11:22 UTC, Seb wrote:
On Thursday, 9 August 2018 at 00:07:05 UTC, Seb wrote:
(It uses the version from DUB and updates itself once daily,
but somehow dub still lists 0.4.1 at the moment)
It looks like you didn't push the git tag to GitHub:
https://github.com/pbackus/sumtype/releases
One of these days, I'll learn. Should be there now.
SumType without initialization doesn't fail if first type has
@disabled this().
In SumType need be something like this:
struct SumType(...){
///...
static if(Types.length > 0 && __traits(compiles, (){Types[0]
tmp;}()) == false){
///Types[0] has disabled this()
@disable this();
}
///....
}
method toString is not template. (why is there in the first
place?)
SumType can have zero TypeArgs but then tryMatch fail:
auto st = SumType!();
st.tryMatch!((_) => 1); //fail at compile time with bad error
message.
in matchImpl can by something like this:
static if(Types.length == 0){
static if(exhaustive) {
static assert(0, "No value to match");
} else {
throw new MatchException("No value to match");
}
}
else{
///...
}
or:
struct SumType(TypeArgs...)
if(TypeArgs.length > 0){
}