Merge pull request #46 from dukc/copyableUnits

Allowed copying of tagged unions containing unit values
This commit is contained in:
Sönke Ludwig 2020-02-21 15:42:26 +01:00 committed by GitHub
commit c658b37bdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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)