combine

Creates a "combined" structure from main and default_. The combined structure contains member values from main whenever !isNull for this value and otherwise values from default_.

  1. S.Regular combine(S.WithDefaults main, S.Regular default_)
    deprecated
    S.Regular
    combine
    (
    S
    )
    (
    S.WithDefaults main
    ,
    S.Regular default_
    )
  2. S.Regular combine(S.WithDefaults main, S.WithDefaults default_)
  3. S.Regular combine(S.WithDefaults main, S.Func default_)

Examples

mixin StructParams!("S", int, "x", float, "y");
immutable S.WithDefaults combinedMain = { x: 12 }; // y is default-initialized
immutable S.Regular combinedDefault = { x: 11, y: 3.0 };
immutable combined = combine(combinedMain, combinedDefault);
assert(combined.x == 12 && combined.y == 3.0);

Note that we cannot use struct literals like S.Regular(x: 11, y: 3.0) in the current version (v2.084.1) of D, just because current version of D does not have this feature. See DIP71.

Meta