From c42c9a4e57526c1b16065ad3f6c908b87bb94811 Mon Sep 17 00:00:00 2001 From: dukc Date: Fri, 21 Feb 2020 18:00:19 +0200 Subject: [PATCH] Allowed copying of tagged unions containing unit values --- source/taggedalgebraic/taggedunion.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/taggedalgebraic/taggedunion.d b/source/taggedalgebraic/taggedunion.d index 90bf434..9c446cb 100644 --- a/source/taggedalgebraic/taggedunion.d +++ b/source/taggedalgebraic/taggedunion.d @@ -39,6 +39,7 @@ align(commonAlignment!(UnionKindTypes!(UnionFieldEnum!U))) struct TaggedUnion { import std.traits : FieldTypeTuple, FieldNameTuple, Largest, hasElaborateCopyConstructor, hasElaborateDestructor, isCopyable; + import std.meta : templateOr; import std.ascii : toUpper; alias FieldDefinitionType = U; @@ -104,7 +105,7 @@ align(commonAlignment!(UnionKindTypes!(UnionFieldEnum!U))) struct TaggedUnion } // postblit constructor - static if (!allSatisfy!(isCopyable, FieldTypes)) { + static if (!allSatisfy!(templateOr!(isCopyable, isUnitType), FieldTypes)) { @disable this(this); } else static if (anySatisfy!(hasElaborateCopyConstructor, FieldTypes)) { this(this)