Re: Two things I thought would be simple

2018-03-08 Thread Steven Schveighoffer via Digitalmars-d
On 3/8/18 3:29 AM, Shachar Shemesh wrote: On 07/03/18 17:11, Steven Schveighoffer wrote: Well, you could do it with templates, but obviously that is less desirable: void func2(Args...)(Args args) if(is(typeof(func(args { return func(args); } I never understood why anyone would use "is"

Re: Two things I thought would be simple

2018-03-08 Thread Shachar Shemesh via Digitalmars-d
On 07/03/18 17:11, Steven Schveighoffer wrote: Well, you could do it with templates, but obviously that is less desirable: void func2(Args...)(Args args) if(is(typeof(func(args { return func(args); } I never understood why anyone would use "is" for checking compilability when we have

Re: Two things I thought would be simple

2018-03-07 Thread Timon Gehr via Digitalmars-d
On 07.03.2018 18:23, Jonathan M Davis wrote: However, even doing something like auto func2(Parameters!func args = AliasSeq!(1, 2, 3)) { return func(args); } doesn't work properly. If that version of the function is used, then the call which passes all three arguments compiles, but the

Re: Two things I thought would be simple

2018-03-07 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, March 07, 2018 18:59:51 Shachar Shemesh via Digitalmars-d wrote: > On 07/03/18 16:42, Jonathan M Davis wrote: > > AFAIK, there's no way to get the values of default arguments with type > > inferrence > > I used that way right there in the code. ParameterDefaults!func return a >

Re: Two things I thought would be simple

2018-03-07 Thread Shachar Shemesh via Digitalmars-d
On 07/03/18 16:42, Jonathan M Davis wrote: AFAIK, there's no way to get the values of default arguments with type inferrence I used that way right there in the code. ParameterDefaults!func return a tuple with the arguments. The problem is that "Tuple var = Tuple" does not work. Different

Re: Two things I thought would be simple

2018-03-07 Thread Steven Schveighoffer via Digitalmars-d
On 3/7/18 9:20 AM, Shachar Shemesh wrote: import std.traits; import std.stdio; void func(int a, int b=2, int c=3) {     return a+b+c; } void func2(Parameters!func args = ParameterDefaults!func) {     return func(args); } void main() {     writeln(func2(1));     writeln(func2(1,1));    

Re: Two things I thought would be simple

2018-03-07 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, March 07, 2018 16:20:19 Shachar Shemesh via Digitalmars-d wrote: > import std.traits; > import std.stdio; > > void func(int a, int b=2, int c=3) { > return a+b+c; > } > > void func2(Parameters!func args = ParameterDefaults!func) { > return func(args); > } > > void main() {