Re: Template reference parameter

2015-03-23 Thread ketmar via Digitalmars-d-learn
On Tue, 24 Mar 2015 00:54:12 +, weaselcat wrote: > On Monday, 23 March 2015 at 22:39:28 UTC, rumbu wrote: > >> I have only one template and I think it's impossible to define >> specializations since it's supposed that a random member of A... will >> be passed sometime by reference: > > auto

Re: Template reference parameter

2015-03-23 Thread weaselcat via Digitalmars-d-learn
On Monday, 23 March 2015 at 22:39:28 UTC, rumbu wrote: I have only one template and I think it's impossible to define specializations since it's supposed that a random member of A... will be passed sometime by reference: auto ref? http://dlang.org/template.html#auto-ref-parameters

Re: Template reference parameter

2015-03-23 Thread ketmar via Digitalmars-d-learn
On Mon, 23 Mar 2015 22:39:27 +, rumbu wrote: > It's working, but I don't like the &value thing, ref would be better. alas. you can write a complex mixin that will generate the appropriate templates for you, though, so you'll be able to do something like this: mixin(MulticastDelegate!(`with

Re: Template reference parameter

2015-03-23 Thread rumbu via Digitalmars-d-learn
On Monday, 23 March 2015 at 22:13:37 UTC, ketmar wrote: On Mon, 23 Mar 2015 22:01:03 +, rumbu wrote: I'm trying to construct a struct template where one of the template parameters is passed by reference (as option) struct S(T, U) { void opCall(T t, U u) { } } alias X = S!(T, U); alia

Re: Template reference parameter

2015-03-23 Thread ketmar via Digitalmars-d-learn
On Mon, 23 Mar 2015 22:01:03 +, rumbu wrote: > I'm trying to construct a struct template where one of the template > parameters is passed by reference (as option) > > struct S(T, U) > { > void opCall(T t, U u) { } > } > > alias X = S!(T, U); > alias RX = S!(T, ref U); //not working > >