diff --git a/source/taggedalgebraic.d b/source/taggedalgebraic.d index 7b0e42a..37d7792 100644 --- a/source/taggedalgebraic.d +++ b/source/taggedalgebraic.d @@ -611,6 +611,11 @@ bool hasType(T, U)(in ref TaggedAlgebraic!U ta) } assert(false); // never reached } +/// ditto +bool hasType(T, U)(in TaggedAlgebraic!U ta) +{ + return hasType!(T, U)(ta); +} /// unittest { @@ -641,6 +646,18 @@ unittest { // issue #1 assert(ta.hasType!int); } +unittest { + union U { + int a; + float b; + } + alias TA = TaggedAlgebraic!U; + + const(TA) test() { return TA(12); } + assert(test().hasType!int); +} + + /** Gets the value stored in an algebraic type based on its data type. */ ref inout(T) get(T, U)(ref inout(TaggedAlgebraic!U) ta)