On Monday, 11 February 2019 at 22:32:59 UTC, Vladimir Marchevsky wrote:
On Monday, 11 February 2019 at 17:03:36 UTC, Atila Neves wrote:
import kwargs;

struct Foo { string value; }
struct Bar { string value; }
struct Baz { string value; }

size_t funImpl(in Foo foo, in Bar bar = Bar("lebar"), in Baz baz = Baz("lebaz")) { return foo.value.length + bar.value.length + baz.value.length;
}

alias fun = kwargify!funImpl;

fun(Foo()).should == 10;
fun(Bar("b"), Foo("fo")).should == 8;
fun(Bar("b"), Baz("ba"), Foo("foo")).should == 6;

So all arguments should have different types, right? Like here we have 3 strings wrapped in structs to distinguish them

Yes, they all have to have different types.

Reply via email to