Instantiate!(Template, args) in Phobos?

David Nadlinger via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 22 12:09:40 PDT 2016


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 solution?

 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]!(...) is not 
valid) or a template
  * returning another template (e.g. Foo!(Bar)!(Baz) is not 
allowed).
  */
// TODO: Consider publicly exposing this, maybe even if only for 
better
// understandability of error messages.
alias Instantiate(alias Template, Params...) = Template!Params;
---

;)

  — David


More information about the Digitalmars-d-learn mailing list