Instantiate!(Template, args) in Phobos?
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Apr 22 06:40:28 PDT 2016
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!(...).staticEx` either:
>
> staticex.d(3): Error: template identifier 'staticEx' is not a member of
> template 'staticex.staticEx!(Exception, "Look ma, @nogc
> exception!").staticEx(string file = __FILE__, uint line = __LINE__)()'
> staticex.d(20): Error: template instance staticex.staticEx!("Look ma,
> @nogc exception!", "staticex.d", 20u) error instantiating
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 think you are right, this cannot be done without such a template. It
brings back access to the eponymous nested template, interesting. I
think we should add it.
>> I would think something with AliasSeq could come in handy, it's the way
>> to alias a compile-time list.
>
> Not sure how that would help.
I didn't realize what the issue was.
-Steve
More information about the Digitalmars-d-learn
mailing list