alias this private?
    js.mdnq 
    js_adddot+mdng at gmail.com
       
    Sun Dec  9 01:42:47 PST 2012
    
    
  
Actually, it doesn't seem to work ;/ Your code worked but mine 
does unless I make it public. It is a public/private issue and I 
get a ton of errors:
module main;
import std.stdio;
class A
{
	public:
		string Name;
		struct B(T)
		{
			private:
			//public:
				T Value;
			public:
				alias Value this;
				T opAssign(F)(F v)
				{
					//writeln(Name ~ " ...");
					Value = cast(T)v;
					return Value;
				}
	
		}
	
		B!int b;
}
int main(string[] argv)
{
	A c = new A();
	c.b = 34;
	writeln(c.b);
	getchar();
	return 0;
}
Error: template std.conv.toImpl does not match any function 
template declaration
Error: template std.conv.toImpl cannot deduce template function 
from argument types !(int)(B!(int))
Error: template instance toImpl!(int) errors instantiating 
template
Error: template instance std.conv.to!(int).to!(B!(int)) error 
instantiating
So while it might "work" in the simple case it doesn't seem to 
actually work...
    
    
More information about the Digitalmars-d-learn
mailing list