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

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

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 `=

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:

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!(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);