Re: Should the compiler be failing to infer template args here?

2020-06-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/19/20 12:38 PM, SealabJaster wrote: On Friday, 19 June 2020 at 16:31:50 UTC, Paul Backus wrote: This is a known issue: https://issues.dlang.org/show_bug.cgi?id=1807 "Reported: 2008"... yikes. Thanks anyway, glad to know I wasn't just going mad :) It's somewhat difficult to solve, beca

Re: Should the compiler be failing to infer template args here?

2020-06-19 Thread SealabJaster via Digitalmars-d-learn
On Friday, 19 June 2020 at 16:31:50 UTC, Paul Backus wrote: This is a known issue: https://issues.dlang.org/show_bug.cgi?id=1807 "Reported: 2008"... yikes. Thanks anyway, glad to know I wasn't just going mad :)

Re: Should the compiler be failing to infer template args here?

2020-06-19 Thread Paul Backus via Digitalmars-d-learn
On Friday, 19 June 2020 at 16:16:55 UTC, SealabJaster wrote: If you take a look at this code here: https://godbolt.org/z/4T3uLh You can see that when using a templated alias, the compiler fails to infer the T template parameter, but only when using the function that also asks for the alias, i

Should the compiler be failing to infer template args here?

2020-06-19 Thread SealabJaster via Digitalmars-d-learn
If you take a look at this code here: https://godbolt.org/z/4T3uLh You can see that when using a templated alias, the compiler fails to infer the T template parameter, but only when using the function that also asks for the alias, instead of the original type. I was just wondering if this is

Re: Template args

2016-07-16 Thread Andrey via Digitalmars-d-learn
On Saturday, 16 July 2016 at 00:29:12 UTC, Max Klimov wrote: On Friday, 15 July 2016 at 23:07:20 UTC, Andrey wrote: Hi guys! Can any one tell me - how to pass an array of int's in to the template struct at compile-time, and how to use int there? Like this: https://dpaste.dzfl.pl/844057da81e9

Re: Template args

2016-07-15 Thread Max Klimov via Digitalmars-d-learn
On Friday, 15 July 2016 at 23:07:20 UTC, Andrey wrote: Hi guys! Can any one tell me - how to pass an array of int's in to the template struct at compile-time, and how to use int there? Like this: https://dpaste.dzfl.pl/844057da81e9 ?

Template args

2016-07-15 Thread Andrey via Digitalmars-d-learn
Hi guys! Can any one tell me - how to pass an array of int's in to the template struct at compile-time, and how to use int there?

Re: Instantiate!(Template, args) in Phobos?

2016-04-25 Thread Nick Treleaven via Digitalmars-d-learn
On 25/04/2016 11:16, Nick Treleaven wrote: On Friday, 22 April 2016 at 19:09:40 UTC, David Nadlinger wrote: alias Instantiate(alias Template, Params...) = Template!Params; Ah, maybe I'd even seen this in passing and forgot. Good point about aliasSeq template elements, let's make this public.

Re: Instantiate!(Template, args) in Phobos?

2016-04-25 Thread Nick Treleaven via Digitalmars-d-learn
On Friday, 22 April 2016 at 19:09:40 UTC, David Nadlinger wrote: From std.meta: --- /* * Instantiates the given template with the given list of parameters. * * Used to work around syntactic limitations of D with regard to instantiating * a template from an alias sequence (e.g. T[0]!(...)

Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread David Nadlinger via Digitalmars-d-learn
On Thursday, 21 April 2016 at 14:47:55 UTC, Nick Treleaven wrote: I found std.meta.ApplyLeft but it doesn't seem to work here. I've needed this before and ended up doing a workaround with a template block and temporary alias but it might be nice if Phobos had this. Or is there a simpler solutio

Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Nick Treleaven via Digitalmars-d-learn
On 22/04/2016 14:40, Steven Schveighoffer wrote: OK, I get it. I think this used to work, but I think D has long since disallowed direct access to eponymous members. So what you really want to do is: staticEx!(Exception, msg)!(file, line), but of course this doesn't follow proper grammar. I th

Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/22/16 6:50 AM, Nick Treleaven wrote: On 21/04/2016 18:03, Steven Schveighoffer wrote: This doesn't work? alias staticEx(string msg, string file = __FILE__, size_t line = __LINE__) = staticEx!(Exception, msg).staticEx!(file, line); No, nor using the module dot prefix `= .staticEx!(...).st

Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Nick Treleaven via Digitalmars-d-learn
On 21/04/2016 18:03, Steven Schveighoffer wrote: This doesn't work? alias staticEx(string msg, string file = __FILE__, size_t line = __LINE__) = staticEx!(Exception, msg).staticEx!(file, line); No, nor using the module dot prefix `= .staticEx!(...).staticEx` either: staticex.d(3): Error: temp

Re: Instantiate!(Template, args) in Phobos?

2016-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/21/16 10:47 AM, Nick Treleaven wrote: Hi, There doesn't seem to be something like this in Phobos: alias Instantiate(alias Template, T...) = Template!T; Here's an example of why I need it: alias staticEx(string msg, string file = __FILE__, size_t line = __LINE__) = Instantiate!(.stati

Instantiate!(Template, args) in Phobos?

2016-04-21 Thread Nick Treleaven via Digitalmars-d-learn
Hi, There doesn't seem to be something like this in Phobos: alias Instantiate(alias Template, T...) = Template!T; Here's an example of why I need it: alias staticEx(string msg, string file = __FILE__, size_t line = __LINE__) = Instantiate!(.staticEx!(Exception, msg), file, line); tem

Re: Different class template args to generate same template instance?

2009-11-02 Thread Nick Sabalausky
"Nick Sabalausky" wrote in message news:hcnlh7$ms...@digitalmars.com... > "downs" wrote in message > news:hcnjit$4n...@digitalmars.com... >> Nick Sabalausky wrote: >>> "BCS" wrote in message >>> news:a6268ffc3898cc29d1f554d...@news.digitalmars.com... Hello Nick, > So...is th

Re: Different class template args to generate same template instance?

2009-11-02 Thread Nick Sabalausky
"downs" wrote in message news:hcnjit$4n...@digitalmars.com... > Nick Sabalausky wrote: >> "BCS" wrote in message >> news:a6268ffc3898cc29d1f554d...@news.digitalmars.com... >>> Hello Nick, >>> >>> So...is there any trickery I could do so that SubFoo!("sam") and SubFoo!("sam", "human") w

Re: Different class template args to generate same template instance?

2009-11-02 Thread downs
Nick Sabalausky wrote: > "BCS" wrote in message > news:a6268ffc3898cc29d1f554d...@news.digitalmars.com... >> Hello Nick, >> >> >>> So...is there any trickery I >>> could do so that SubFoo!("sam") and SubFoo!("sam", "human") would >>> resolve to the same subclass of Foo? >> Make a SubFoo!(char[] s

Re: Different class template args to generate same template instance?

2009-11-02 Thread Nick Sabalausky
"BCS" wrote in message news:a6268ffc3898cc29d1f554d...@news.digitalmars.com... > Hello Nick, > > >> So...is there any trickery I >> could do so that SubFoo!("sam") and SubFoo!("sam", "human") would >> resolve to the same subclass of Foo? > > Make a SubFoo!(char[] s) that does your logic and if it

Re: Different class template args to generate same template instance?

2009-11-02 Thread BCS
Hello Nick, So...is there any trickery I could do so that SubFoo!("sam") and SubFoo!("sam", "human") would resolve to the same subclass of Foo? Make a SubFoo!(char[] s) that does your logic and if it passesa alises to SubFoo!(s,"")

Different class template args to generate same template instance?

2009-11-02 Thread Nick Sabalausky
I'd like to have a sub-class that's templated on a potentially-duplicated name and an optional disambiguating type. To illustrate: class Foo { } /* Three possible names/types are: - sam, human - zoe, human - zoe, starship */ class SubFoo(char[] name, char[] type) { static if(name == "sam" &&