Instantiate!(Template, args) in Phobos?

Nick Treleaven via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 21 07:47:55 PDT 2016


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

template staticEx(T:Throwable, args...)
{
	auto staticEx(string file = __FILE__, size_t line = __LINE__)()
	...

Full code:
http://dpaste.dzfl.pl/810e55b1acd76

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?


More information about the Digitalmars-d-learn mailing list