www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - struct requiring this access for template?

I encountered an odd error while using template, it reduced to this... and I
was wondering whats going on.

//Regex.d(20): Error: need 'this' to access member x

module templating;

import tango.io.Stdout;

public class TemplatedClass
	const char[] pattern;
	public this(char[] pattern){this.pattern=pattern;}
	public char[] x()
		return this.pattern;
public static TemplatedClass Templated()(char[] pattern)
	return new TemplatedClass(pattern);
public static TemplatedStruct Templated(char[] pattern)()
	return TemplatedStruct(pattern);
public struct TemplatedStruct
	const char[] x;
void main(char[][] args)
	TemplatedStruct x = Templated!("123");
	auto xCheck = Templated!(x.x);//Causes problems?
	auto y = Templated(args[1]);
	auto yCheck = Templated(y.x);//OK
	//Check if we got the right types...
	Stdout("x : ")(typeid(typeof(x))).newline;
	Stdout("y : ")(typeid(typeof(y))).newline;
Nov 15 2008