Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.annotated

Annotated value

License:
Authors:
Ilya Yaroshenko
struct Annotated(T);
A convenience definition of an annotated value.
A structure that behaves like a recursive algebraic type should define enum _serdeRecursiveAlgebraic; member.
Examples:
auto annotations = ["annotation"];
static struct S {double x;}
auto as = Annotated!S(annotations, 5);
assert(as.annotations == annotations);
assert(as.value.x == 5);

static struct C {double x;}
auto ac = Annotated!S(annotations, 5);
assert(ac.annotations == annotations);
assert(ac.value.x == 5);
Examples:
import mir.algebraic;
auto annotations = ["annotation"];
static struct S {double x;}
auto as = Annotated!(Variant!S)(annotations, 5);
assert(as.annotations == annotations);
assert(as.value.x == 5);

static struct C {double x;}
auto ac = Annotated!(Variant!S)(annotations, 5);
assert(ac.annotations == annotations);
assert(ac.value.x == 5);
string[] annotations;
inout @property ref inout(T) value();
@property ref T value(T value);
const bool opEquals(const Annotated rhs);
pure @safe this(Args...)(string[] annotations, Args args);
Parameters:
string[] annotations non-empty array of annotations
Args args arguments to construct value with