alias this to a template function

Jonathan M Davis jmdavisProg at gmx.com
Sun Nov 11 14:48:27 PST 2012


On Sunday, November 11, 2012 23:28:21 Adam D. Ruppe wrote:
> On Sunday, 11 November 2012 at 22:25:11 UTC, Jonathan M Davis
> 
> wrote:
> > You can only alias types and variables. A templated type isn't
> > a type until it's been fully instantiated.
> 
> This compiles today though:
> 
> struct Test{
> 	alias get this;
> 	T get(T)() { return T.init; }
> }
> 
> 
> It is just useless because there's no way to instantiate it
> though the alias this (you must do .get!T).

Weird. I've never seen a situation before where an alias accepted a partially-
instantiated template. I'm _very_ surprised that that compiles.

- Jonathan M Davis


More information about the Digitalmars-d mailing list