From e4c5ec700af1f86fdd2c2103e565c738cd8db3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 22 Nov 2016 18:02:34 +0100 Subject: [PATCH] Add non-ref overload of get(). --- source/taggedalgebraic.d | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/taggedalgebraic.d b/source/taggedalgebraic.d index 31ee09c..1430f94 100644 --- a/source/taggedalgebraic.d +++ b/source/taggedalgebraic.d @@ -609,6 +609,13 @@ ref inout(T) get(T, U)(ref inout(TaggedAlgebraic!U) ta) assert(hasType!(T, U)(ta), () { scope (failure) assert(false); return format("Trying to get %s but have %s.", T.stringof, ta.kind); } ()); return ta.trustedGet!T; } +/// ditto +inout(T) get(T, U)(inout(TaggedAlgebraic!U) ta) +{ + import std.format : format; + assert(hasType!(T, U)(ta), () { scope (failure) assert(false); return format("Trying to get %s but have %s.", T.stringof, ta.kind); } ()); + return ta.trustedGet!T; +} /// Convenience type that can be used for union fields that have no value (`void` is not allowed). struct Void {}