Algebraic

Lightweight version of std.variant.Algebraic that doesn't rely on TypeInfo.

Member functions are, when possible, @safe pure nothrow @nogc.

Storage (packing) is more space-efficient.

TODO support implicit conversions of (un)signed integer type to larger type

Constructors

this
this(Algebraic that)

Copy construct from that.

this
this(T that)

Construct copy from that.

Destructor

~this
~this()

Destruct.

Public Imports

nxt.maxsize_trait
public import nxt.maxsize_trait : maxSizeOf;
std.digest
public import std.digest : isDigest;

Members

Aliases

nullify
alias nullify = clear

Force this to the null/uninitialized/unset/undefined state.

Functions

clear
void clear()

Force this to the null/uninitialized/unset/undefined state.

get
inout(T) get()
inout(Types[index]) get()

Get Value of type T.

hasValue
bool hasValue()
ofType
bool ofType()
opAssign
void opAssign(typeof(null) )

Nullable type support.

peek
inout(T)* peek()

If the Algebraic object holds a value of the exact type T, returns a pointer to that value. Otherwise, returns null. In cases where T is statically disallowed, peek will not compile.

toDigest
void toDigest(Digest digest)

TODO use !hasAliasing?

toHTML
void toHTML(void delegate(scope const(char)[]) sink)

Manifest constants

hasFixedSize
enum hasFixedSize;

Is true if all Types stored in this Algebraic has the same length.

mayHaveAliasing
enum mayHaveAliasing;

Is true iff this may have aliasing through any of Types.

Static variables

nullValue
auto nullValue;

Nullable type support.

Variables

allowsAssignmentFrom
enum bool allowsAssignmentFrom(U);

Is true if U is allowed to be assigned to this.

See Also

https://forum.dlang.org/post/jfasmgwoffmbtuvrtxey@forum.dlang.org

TODO add warnings about combining byte, short, int, long, etc. TODO add warnings about combining ubyte, ushort, uint, ulong, etc.

TODO Use

align(1) struct Unaligned { align(1): ubyte filler; Victim* p; }

http://forum.dlang.org/post/osfrjcuabwscvrecuvre@forum.dlang.org https://forum.dlang.org/post/jfasmgwoffmbtuvrtxey@forum.dlang.org https://forum.dlang.org/post/tdviqyzrcpttwwnvlzpv@forum.dlang.org https://issues.dlang.org/show_bug.cgi?id=15399

Meta