lu.meld

This module contains the meldInto functions; functions that take two structs or classes of the same type and combine them, creating a resulting object with the union of the members of both parents. Array and associative array variants exist too.

Members

Enums

MeldingStrategy
enum MeldingStrategy

To what extent a source should overwrite a target when melding.

Unmeldable
enum Unmeldable

UDA conveying that this member's value cannot or should not be melded.

Functions

meldInto
void meldInto(QualThing meldThis, Thing intoThis)

Takes two structs or classes of the same type and melds them together, making the members a union of the two.

meldInto
void meldInto(Array1 meldThis, Array2 intoThis)

Takes two arrays and melds them together, making a union of the two.

meldInto
void meldInto(QualAA meldThis, AA intoThis)

Takes two associative arrays and melds them together, making a union of the two.

Examples

struct Foo
{
    string abc;
    string def;
    int i;
    float f;
    double d;
}

Foo f1; // = new Foo;
f1.abc = "ABC";
f1.def = "DEF";

Foo f2; // = new Foo;
f2.abc = "this won't get copied";
f2.def = "neither will this";
f2.i = 42;
f2.f = 3.14f;

f2.meldInto(f1);

with (f1)
{
    import std.math : isNaN;

    assert(abc == "ABC");
    assert(def == "DEF");
    assert(i == 42);
    assert(f == 3.14f);
    assert(d.isNaN);
}

Meta