ProviderWithDefaults

Create provider with defaults of type ParamsType.Regular from a provider Base.

ParamsType should be like a struct S created with

mixin StructParams!("S", int, "x", float, "y"); // see struct-params package

Then use it like this:

1 float calc(int x, float y) {
2     return x * y;
3 }
4 immutable S.WithDefaults myDefaults = { x: 3, y: 2.1 }; // or `immutable S.Regular myDefaults`
5 alias MyProvider = ProviderWithDefaults!(Callable!calc, S, myDefaults);
6 
7 immutable S.WithDefaults providerParams = { x: 2 }; // note y is default initialized to null
8 auto provider = new MyProvider;
9 assert(provider.callWithDefaults(providerParams) - 4.2 < 1e-6);
class ProviderWithDefaults : Base(
Base
ParamsType
alias defaults
) {}

Meta