Allowed copying of tagged unions containing unit values

This commit is contained in:
dukc 2020-02-21 18:00:19 +02:00
parent 30de5843ba
commit c42c9a4e57

View file

@ -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)