Re: Append variadic template parameters

2017-02-05 Thread Mark Fisher via Digitalmars-d-learn
On Sunday, 5 February 2017 at 21:51:14 UTC, Meta wrote: On Sunday, 5 February 2017 at 20:36:57 UTC, Mark Fisher wrote: I want to write a template: static auto ref BindArg(alias Func,alias arg,args...)() { return Func(arg,args); } where Func is called with 'arg' followed by the 'args'

Re: Append variadic template parameters

2017-02-05 Thread Meta via Digitalmars-d-learn
On Sunday, 5 February 2017 at 20:36:57 UTC, Mark Fisher wrote: I want to write a template: static auto ref BindArg(alias Func,alias arg,args...)() { return Func(arg,args); } where Func is called with 'arg' followed by the 'args' parameters. eg: string f(string a,int b,int c); BindA

Re: Append variadic template parameters

2017-02-05 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 5 February 2017 at 20:36:57 UTC, Mark Fisher wrote: static auto ref BindArg(alias Func,alias arg,args...)() { return Func(arg,args); } [...] BindArg(f,"1",2,3); You forgot an exclamation mark there: BindArg!(f,"1",2,3);

Re: Initialization of dynamic multidimensional array

2017-02-05 Thread Daniel Kozak via Digitalmars-d-learn
http://stackoverflow.com/questions/24600796/d-set-default-value-for-a-struct-member-which-is-a-multidimensional-static-arr/24754361#24754361 Dne 5.2.2017 v 21:33 berni via Digitalmars-d-learn napsal(a): With X not known at compile time: auto arr = new int[][](X,X); for (int i=0;i Is there an

Append variadic template parameters

2017-02-05 Thread Mark Fisher via Digitalmars-d-learn
I want to write a template: static auto ref BindArg(alias Func,alias arg,args...)() { return Func(arg,args); } where Func is called with 'arg' followed by the 'args' parameters. eg: string f(string a,int b,int c); BindArg(f,"1",2,3); The compiler throws an error: Error: function f (str

Initialization of dynamic multidimensional array

2017-02-05 Thread berni via Digitalmars-d-learn
With X not known at compile time: auto arr = new int[][](X,X); for (int i=0;i Is there anything better for this? I mean, the program will fill the array with zeroes, just to overwrite all of them with -1. That's wasted execution time and doesn't feel D-ish to me.

Re: Need help to compile code with traits

2017-02-05 Thread Xavier Bigand via Digitalmars-d-learn
Le 05/02/2017 à 18:32, Basile B. a écrit : On Sunday, 5 February 2017 at 14:59:04 UTC, Xavier Bigand wrote: Hi, I am trying to create an allocator that don't use the GC, and I have issues for the initialization of member before calling the constructor. Here is my actual code : mixin template N

Re: Need help to compile code with traits

2017-02-05 Thread Basile B. via Digitalmars-d-learn
On Sunday, 5 February 2017 at 14:59:04 UTC, Xavier Bigand wrote: Hi, I am trying to create an allocator that don't use the GC, and I have issues for the initialization of member before calling the constructor. Here is my actual code : mixin template NogcAllocator(T) { static T

Need help to compile code with traits

2017-02-05 Thread Xavier Bigand via Digitalmars-d-learn
Hi, I am trying to create an allocator that don't use the GC, and I have issues for the initialization of member before calling the constructor. Here is my actual code : mixin template NogcAllocator(T) { static TnogcNew(T, Args...)(Args args) @nogc { imp

Re: GC question

2017-02-05 Thread Cym13 via Digitalmars-d-learn
On Sunday, 5 February 2017 at 04:22:30 UTC, rikki cattermole wrote: On 05/02/2017 5:02 PM, thedeemon wrote: snip It may look so from a distance. But in my experience it's not that bad. In most software I did in D it did not matter really (it's either 64-bit or short lived programs) and the co

Re: Is there anything fundamentally wrong with this code?

2017-02-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, February 05, 2017 02:19:35 Era Scarecrow via Digitalmars-d-learn wrote: > On Friday, 3 February 2017 at 18:37:15 UTC, Johan Engelen wrote: > > The error is in this line. Instead of assigning to the > > `postProc` at module scope, you are defining a new local > > variable and assigning t