Algebraic

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

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

Storage (packing) is more space-efficient.

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

@safe pure
struct Algebraic (
Types...
) {}

Constructors

this
this(Algebraic that)

Copy construct from that.

this
this(T that)

Construct copy from that.

Destructor

~this
~this()

Destruct.

Members

Aliases

CommonType
alias CommonType = StdCommonType!Types
Undocumented in source.
Ix
alias Ix = ubyte
Undocumented in source.
canStore
alias canStore = ofType
Undocumented in source.
isType
alias isType = ofType
Undocumented in source.
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.

commonValue
CommonType commonValue()
Undocumented in source. Be warned that the author may not have intended to support it.
currentSize
size_t currentSize()
Undocumented in source. Be warned that the author may not have intended to support it.
hasValue
bool hasValue()
isNull
bool isNull()
Undocumented in source. Be warned that the author may not have intended to support it.
ofType
bool ofType()
opAssign
Algebraic opAssign(T that)
Undocumented in source. Be warned that the author may not have intended to support it.
opAssign
void opAssign(typeof(null) )

Nullable type support.

opCmp
int opCmp(Algebraic that)
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(U that)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Algebraic that)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Algebraic that)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(T that)
Undocumented in source. Be warned that the author may not have intended to support it.
to
auto ref to()
Undocumented in source. Be warned that the author may not have intended to support it.
toDigest
void toDigest(Digest digest)
Undocumented in source. Be warned that the author may not have intended to support it.
toHash
hash_t toHash()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
void toString(Sink sink)
Undocumented in source. Be warned that the author may not have intended to support it.

Imports

isDigest (from std.digest)
public import std.digest : isDigest;
Undocumented in source.

Manifest constants

dataMaxSize
enum dataMaxSize;
Undocumented in source.
hasCommonType
enum hasCommonType;
Undocumented in source.
hasFixedSize
enum hasFixedSize;

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

maxTypesCount
enum maxTypesCount;
Undocumented in source.
mayHaveAliasing
enum mayHaveAliasing;

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

name
enum name;
Undocumented in source.
typeCount
enum typeCount;
Undocumented in source.
typeNames
enum typeNames;
Undocumented in source.
typeSizes
enum typeSizes;
Undocumented in source.

Properties

get
inout(T) get [@property getter]
inout(Types[index]) get [@property getter]

Get Value of type T.

peek
inout(T)* peek [@property getter]

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.

toHTML
Sink toHTML [@property setter]

Static variables

nullValue
auto nullValue;

Nullable type support.

typeNamesRT
auto typeNamesRT;
Undocumented in source.

Templates

maxSizeOf (from nxt.maxsize_trait)
template maxSizeOf(Ts...) via public import nxt.maxsize_trait : maxSizeOf;

Get maximum size of types Ts.

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; }

https://github.com/Geod24/minivariant

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